/* ===== STYLES_DIALOG.CSS - APPLE-STYLE MOBILE DIALOG OPTIMIZACIÓN ===== */

/* ----------------------------- VARIABLES ----------------------------- */

:root {
    --dialog-bg: rgba(28, 28, 30, 0.98);
    --dialog-border: rgba(72, 72, 74, 0.4);
    --text-primary: #f5f5f7;
    --text-secondary: #aeaeb2;
    --text-tertiary: #98989d;
    --accent-color: #0a84ff;
    --backdrop-color: rgba(0, 0, 0, 0.5);
    --card-bg: rgba(58, 58, 60, 0.6);
}

/* ----------------------------- BACKDROP ----------------------------- */

.backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
}

.backdrop.active {
    opacity: 1;
    background: var(--backdrop-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: all;
}

/* ----------------------------- DIALOG BASE - DESKTOP ----------------------------- */

dialog {
    max-width: 1400px;
    width: calc(100% - 80px);
    max-height: 85vh;
    padding: 0;
    border: none;
    border-radius: 24px;
    background: var(--dialog-bg);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 0 1px var(--dialog-border);
    overflow: hidden;
    z-index: 9999;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    opacity: 0;
    scale: 0.95;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

dialog[open] {
    opacity: 1;
    scale: 1;
}

dialog::backdrop {
    background: transparent;
}

/* ----------------------------- DIALOG CONTENT - SCROLLBAR ----------------------------- */

.dialog-content {
    padding: 48px 64px;
    overflow-y: auto;
    max-height: 85vh;
    overscroll-behavior: contain;
}

/* Scrollbar estilo Apple Dark Mode */
dialog::-webkit-scrollbar,
.dialog-content::-webkit-scrollbar {
    width: 8px;
}

dialog::-webkit-scrollbar-track,
.dialog-content::-webkit-scrollbar-track {
    background: transparent;
}

dialog::-webkit-scrollbar-thumb,
.dialog-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    border: 1px solid transparent;
    background-clip: content-box;
    transition: background 0.2s ease;
}

dialog::-webkit-scrollbar-thumb:hover,
.dialog-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.22);
}

dialog::-webkit-scrollbar-thumb:active,
.dialog-content::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.32);
}

/* ----------------------------- HEADER ----------------------------- */

.dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 20px;
}

.dialog-company-info {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.dialog-logo {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    border: 1px solid var(--dialog-border);
    flex-shrink: 0;
    overflow: hidden;
}

.dialog-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.dialog-title-group h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.dialog-title-group h3 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.dialog-period {
    font-size: 14px;
    color: var(--accent-color);
    font-weight: 500;
}

/* ----------------------------- CLOSE BUTTON - APPLE MINIMALIST STYLE ----------------------------- */

.close-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #98989d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    opacity: 0.7;
    padding: 0;
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    opacity: 1;
}

.close-button:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.12);
}

/* ----------------------------- CLOSE BUTTON ALTERNATIVO - ESTILO macOS SEMÁFORO ----------------------------- */

.close-button.macos-style {
    width: 12px;
    height: 12px;
    background: #ff5f57;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    position: relative;
    opacity: 1;
}

.close-button.macos-style::before {
    content: '×';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: 600;
    color: #4d0000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.close-button.macos-style:hover::before {
    opacity: 1;
}

.close-button.macos-style:hover {
    background: #ff5f57;
    transform: none;
}

.close-button.macos-style:active {
    background: #e04b43;
    transform: scale(0.95);
}

/* ----------------------------- SECTIONS ----------------------------- */

.dialog-section {
    margin-bottom: 32px;
}

.dialog-section h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.dialog-section p {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.dialog-section ul {
    list-style: none;
    padding: 0;
}

.dialog-section li {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    padding-left: 24px;
    position: relative;
}

.dialog-section li::before {
    content: '•';
    position: absolute;
    left: 8px;
    color: var(--accent-color);
    font-size: 20px;
    line-height: 1;
}

/* ----------------------------- SKILLS ----------------------------- */

.dialog-skills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.dialog-skill-tag {
    background: rgba(10, 132, 255, 0.15);
    color: var(--accent-color);
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(10, 132, 255, 0.3);
    transition: all 0.2s ease;
}

.dialog-skill-tag:hover {
    background: rgba(10, 132, 255, 0.25);
    transform: translateY(-2px);
}

/* ----------------------------- MOBILE OPTIMIZATION (TABLET) ----------------------------- */

@media (max-width: 768px) {
    dialog {
        max-width: calc(100% - 32px);
        width: calc(100% - 32px);
        max-height: 90vh;
        border-radius: 20px;
    }

    .dialog-content {
        padding: 32px 24px;
        max-height: 90vh;
    }

    .dialog-header {
        flex-direction: column;
        gap: 16px;
    }

    .dialog-company-info {
        width: 100%;
    }

    .dialog-logo {
        width: 64px;
        height: 64px;
    }

    .dialog-title-group h2 {
        font-size: 24px;
    }

    .dialog-title-group h3 {
        font-size: 18px;
    }

    .close-button {
        align-self: flex-end;
    }
}

/* ----------------------------- MOBILE OPTIMIZATION (PHONE) - APPLE SHEET STYLE ----------------------------- */

@media (max-width: 468px) {
    /* Dialog transformado en Sheet estilo iOS */
    dialog {
        max-width: 100%;
        width: 100%;
        max-height: 94vh;
        height: 94vh;
        border-radius: 20px 20px 0 0;
        top: auto;
        bottom: 0;
        left: 0;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.6),
                    0 0 0 1px var(--dialog-border);
        margin: 0;
    }

    dialog[open] {
        transform: translateY(0);
        opacity: 1;
    }

    /* Indicador de arrastre estilo iOS */
    dialog::before {
        content: '';
        position: absolute;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 5px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
        z-index: 10;
    }

    /* Safe area para dispositivos con notch */
    .dialog-content {
        padding: 32px 20px;
        padding-top: calc(32px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(32px + env(safe-area-inset-bottom, 20px));
        max-height: 94vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Header optimizado para móvil */
    .dialog-header {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 24px;
        position: relative;
        padding-top: 12px;
    }

    .dialog-company-info {
        width: 100%;
        gap: 16px;
    }

    .dialog-logo {
        width: 56px;
        height: 56px;
        border-radius: 14px;
    }

    .dialog-title-group h2 {
        font-size: 22px;
        line-height: 1.2;
    }

    .dialog-title-group h3 {
        font-size: 16px;
        line-height: 1.3;
    }

    .dialog-period {
        font-size: 13px;
    }

    /* Close button estilo iOS para móvil */
    .close-button,
    .close-button.macos-style {
        position: absolute;
        top: 8px;
        right: 0;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        font-size: 18px;
        background: rgba(58, 58, 60, 0.8);
        backdrop-filter: blur(10px);
        color: var(--text-primary);
        opacity: 1;
        border: none;
    }

    .close-button.macos-style::before {
        content: '×';
        opacity: 1;
        color: var(--text-primary);
        font-size: 18px;
        font-weight: 400;
    }

    .close-button:active,
    .close-button.macos-style:active {
        transform: scale(0.9);
        opacity: 0.8;
        background: rgba(58, 58, 60, 0.9);
    }

    /* Secciones */
    .dialog-section {
        margin-bottom: 28px;
    }

    .dialog-section h4 {
        font-size: 17px;
        margin-bottom: 14px;
    }

    .dialog-section p {
        font-size: 15px;
        line-height: 1.6;
    }

    .dialog-section li {
        font-size: 14px;
        line-height: 1.5;
        margin-bottom: 10px;
        padding-left: 20px;
    }

    .dialog-section li::before {
        font-size: 18px;
        left: 6px;
    }

    /* Skills optimizadas para móvil */
    .dialog-skills {
        gap: 8px;
    }

    .dialog-skill-tag {
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 10px;
    }

    /* Scrollbar más ancha en móvil para mejor usabilidad táctil */
    dialog::-webkit-scrollbar,
    .dialog-content::-webkit-scrollbar {
        width: 4px;
    }

    /* Backdrop más oscuro en móvil */
    .backdrop.active {
        background: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

/* ----------------------------- LANDSCAPE MOBILE ----------------------------- */

@media (max-width: 932px) and (orientation: landscape) {
    dialog {
        max-height: 90vh;
        height: 90vh;
    }

    .dialog-content {
        padding: 24px 20px;
        max-height: 90vh;
    }

    .dialog-header {
        margin-bottom: 20px;
    }

    .dialog-section {
        margin-bottom: 24px;
    }
}

/* ----------------------------- EXTRA SMALL DEVICES ----------------------------- */

@media (max-width: 375px) {
    .dialog-content {
        padding: 28px 16px;
        padding-bottom: calc(28px + env(safe-area-inset-bottom, 20px));
    }

    .dialog-title-group h2 {
        font-size: 20px;
    }

    .dialog-title-group h3 {
        font-size: 15px;
    }

    .dialog-logo {
        width: 48px;
        height: 48px;
    }

    .dialog-skill-tag {
        padding: 7px 12px;
        font-size: 12px;
    }
}

/* ----------------------------- ANIMACIONES ----------------------------- */

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

/* ----------------------------- ACCESIBILIDAD ----------------------------- */

@media (prefers-reduced-motion: reduce) {
    dialog,
    .backdrop,
    .close-button,
    .dialog-skill-tag {
        transition: none;
        animation: none;
    }
}

/* ----------------------------- DARK MODE SUPPORT ----------------------------- */

@media (prefers-color-scheme: light) {
    :root {
        --dialog-bg: rgba(255, 255, 255, 0.98);
        --dialog-border: rgba(0, 0, 0, 0.1);
        --text-primary: #1d1d1f;
        --text-secondary: #6e6e73;
        --text-tertiary: #86868b;
        --card-bg: rgba(242, 242, 247, 0.8);
    }

    dialog::-webkit-scrollbar-thumb,
    .dialog-content::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.15);
    }

    dialog::-webkit-scrollbar-thumb:hover,
    .dialog-content::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, 0.25);
    }

    dialog::before {
        background: rgba(0, 0, 0, 0.2);
    }

    .close-button {
        color: #6e6e73;
    }

    .close-button:hover {
        background: rgba(0, 0, 0, 0.05);
        color: var(--text-primary);
    }
}