/* ================================================================
   MENCIÓN FANTASMA — Premium Dark Theme 2025 (Cyan/Teal)
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ===== Custom Properties ===== */
@property --border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

:root {
    --void: #070e13;
    --surface: rgba(12, 22, 28, 0.82);
    --surface-raised: rgba(18, 30, 38, 0.65);
    --accent: #06b6d4;
    --accent-bright: #22d3ee;
    --accent-glow: rgba(6, 182, 212, 0.35);
    --border: rgba(6, 182, 212, 0.10);
    --border-hover: rgba(6, 182, 212, 0.22);
    --text-1: #e8edf0;
    --text-2: #8ca0ac;
    --text-3: #4a6070;
}

/* ===== Base ===== */
* { box-sizing: border-box; }

/* Grid/Flex children must not exceed parent width */
#mainSection {
    max-width: 100%;
    overflow: hidden;
}
#mainSection .grid > * {
    min-width: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--text-1);
}

h1, h2, h3, .font-display { font-family: 'Space Grotesk', system-ui, sans-serif; }

::selection {
    background: rgba(6, 182, 212, 0.3);
    color: #fff;
}

::placeholder {
    color: var(--text-3) !important;
    opacity: 0.7;
}

/* ===== Background ===== */
.gradient-bg {
    background:
        radial-gradient(ellipse 70% 50% at 10% 40%, rgba(6, 182, 212, 0.07) 0%, transparent 100%),
        radial-gradient(ellipse 50% 50% at 90% 15%, rgba(8, 145, 178, 0.05) 0%, transparent 100%),
        radial-gradient(ellipse 60% 40% at 50% 110%, rgba(6, 78, 92, 0.12) 0%, transparent 100%),
        linear-gradient(180deg, #070e13 0%, #0a1319 35%, #0d171e 100%);
    min-height: 100vh;
    position: relative;
}

/* Ambient glow */
.gradient-bg::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle 500px at 25% 45%, rgba(6, 182, 212, 0.04), transparent),
        radial-gradient(circle 400px at 75% 25%, rgba(8, 145, 178, 0.05), transparent);
    animation: ambient 12s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

/* Noise texture */
.gradient-bg::after {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

@keyframes ambient {
    0%   { opacity: 0.3; transform: scale(1); }
    100% { opacity: 1;   transform: scale(1.05); }
}

/* ===== Cards ===== */
.card {
    background: var(--surface);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid var(--border);
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.02);
    position: relative;
    z-index: 1;
    overflow: hidden;
    max-width: 100%;
}

/* ===== Login Card — Animated Gradient Border ===== */
#loginSection .card {
    animation: card-enter 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: visible;
}

#loginSection .card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: conic-gradient(
        from var(--border-angle),
        transparent 30%,
        rgba(6, 182, 212, 0.4) 45%,
        rgba(34, 211, 238, 0.6) 50%,
        rgba(6, 182, 212, 0.4) 55%,
        transparent 70%
    );
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    animation: spin-border 6s linear infinite;
    z-index: -1;
}

@keyframes spin-border {
    to { --border-angle: 360deg; }
}

@keyframes card-enter {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Ghost Icon Glow ===== */
.ghost-icon-wrap {
    position: relative;
}

.ghost-icon-wrap::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: inherit;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.3), transparent 70%);
    animation: icon-pulse 3s ease-in-out infinite;
    z-index: -1;
}

@keyframes icon-pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50%      { opacity: 0.9; transform: scale(1.15); }
}

/* ===== Input Fields ===== */
.input-field {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-1) !important;
    background: rgba(8, 16, 22, 0.7) !important;
    border: 1px solid rgba(6, 182, 212, 0.12) !important;
}

.input-field:focus {
    border-color: rgba(6, 182, 212, 0.4) !important;
    box-shadow:
        0 0 0 3px rgba(6, 182, 212, 0.08),
        0 0 30px rgba(6, 182, 212, 0.06);
    background: rgba(8, 16, 22, 0.85) !important;
}

textarea.input-field {
    resize: vertical;
}

select.input-field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2322d3ee' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 16px center !important;
    background-size: 14px !important;
    padding-right: 40px !important;
}

select option {
    background: #061015;
    color: var(--text-1);
    padding: 8px;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 40px #060d12 inset !important;
    -webkit-text-fill-color: var(--text-1) !important;
    border-color: rgba(6, 182, 212, 0.1) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* ===== Primary Button ===== */
.btn-primary {
    background: linear-gradient(135deg, #0891b2 0%, #06b6d4 40%, #0e7490 100%);
    box-shadow:
        0 4px 20px rgba(6, 182, 212, 0.25),
        0 0 50px rgba(6, 182, 212, 0.08);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 200%; height: 100%;
    background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.12) 50%, transparent 75%);
    transition: left 0.7s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow:
        0 10px 35px rgba(6, 182, 212, 0.4),
        0 0 80px rgba(6, 182, 212, 0.12);
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    transition-duration: 0.1s;
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===== Toasts — Mobile Safe ===== */
.toast {
    max-width: calc(100vw - 40px);
    overflow: hidden;
    word-break: break-word;
}

/* ===== Toast ===== */
.toast {
    transform: translateX(400px);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.01em;
}

.toast.show {
    transform: translateX(0);
}

/* ===== Group Items ===== */
.group-item {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-color: rgba(6, 182, 212, 0.06) !important;
}

.group-item:hover {
    background: rgba(6, 182, 212, 0.05);
    border-color: var(--border-hover) !important;
    transform: translateX(3px);
}

.group-item.selected {
    background: rgba(6, 182, 212, 0.08);
    border-left: 3px solid var(--accent) !important;
    border-color: var(--border-hover) !important;
    box-shadow:
        inset 4px 0 15px rgba(6, 182, 212, 0.06),
        0 0 20px rgba(6, 182, 212, 0.04);
}

/* ===== History Resiliency ===== */
#historyList > div {
    overflow: hidden;
}
#historyList .flex-1 {
    min-width: 0;
}

/* ===== Group Items Resiliency ===== */
.group-item .flex-1 {
    min-width: 0;
}
.group-item h3 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    background: rgba(4, 10, 14, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.loading-overlay .animate-spin {
    border-color: rgba(6, 182, 212, 0.2);
    border-top-color: var(--accent-bright);
}

/* ===== Checkboxes ===== */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
    border-radius: 4px;
}

/* ===== Message Tabs ===== */
.message-tab {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 9999px !important;
    letter-spacing: 0.01em;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(6, 182, 212, 0.18);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(6, 182, 212, 0.35);
}
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(6, 182, 212, 0.18) transparent;
}

/* ===== File Upload ===== */
.upload-zone {
    border: 2px dashed rgba(6, 182, 212, 0.18);
    background: rgba(8, 16, 22, 0.35);
    transition: all 0.25s ease;
    overflow: hidden;
}
.upload-zone:hover {
    border-color: rgba(6, 182, 212, 0.35);
    background: rgba(6, 182, 212, 0.04);
}

.upload-zone.drag-over {
    border-color: rgba(6, 182, 212, 0.6);
    background: rgba(6, 182, 212, 0.08);
    box-shadow: inset 0 0 30px rgba(6, 182, 212, 0.06), 0 0 20px rgba(6, 182, 212, 0.08);
    transform: scale(1.01);
}

.border-dashed {
    border-color: rgba(6, 182, 212, 0.15) !important;
}

/* ===== Dividers ===== */
.border-t.border-gray-200,
.border-b.border-gray-200 {
    border-color: rgba(6, 182, 212, 0.07) !important;
}

/* ===== Global Mobile Responsive ===== */
@media (max-width: 640px) {
    /* Cards: menos padding */
    .card {
        padding: 1rem !important;
    }

    /* Header compacto */
    .header-bar .text-xl {
        font-size: 1rem;
    }
    .header-bar .w-11.h-11 {
        width: 2.25rem !important;
        height: 2.25rem !important;
    }
    .header-bar .text-xl.text-white {
        font-size: 0.75rem !important;
    }

    /* Tabs: más compactas */
    .message-tab {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.65rem !important;
    }

    /* Upload zones: menos padding */
    .upload-zone {
        padding: 1.25rem 1rem !important;
    }

    /* Toasts: posición segura */
    #toastContainer {
        right: 0.75rem !important;
        left: 0.75rem !important;
    }

    /* File preview: compacto */
    #filePreview, #audioPreview {
        padding: 0.5rem 0.75rem !important;
    }

    /* Media preview */
    #mediaPreviewContent img,
    #mediaPreviewContent video {
        max-height: 150px !important;
    }

    /* Botones: solo iconos en móvil */
    .btn-text {
        display: none !important;
    }
    .btn-refresh {
        padding: 0.375rem 0.625rem !important;
    }
}

/* ===== Section Animations ===== */
#mainSection {
    animation: fade-up 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    z-index: 1;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Misc ===== */
.panel-section {
    background: rgba(8, 16, 22, 0.4);
    border: 1px solid rgba(6, 182, 212, 0.08);
}

.header-bar {
    background: rgba(8, 18, 24, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(6, 182, 212, 0.06);
    border-radius: 16px;
}

.btn-logout {
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.12);
    transition: all 0.25s ease;
}
.btn-logout:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.btn-refresh {
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.12);
    transition: all 0.25s ease;
}
.btn-refresh:hover {
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.25);
}

.btn-danger-ghost {
    transition: all 0.2s ease;
}
.btn-danger-ghost:hover {
    color: #fca5a5 !important;
}

/* ===== Voice Recorder ===== */
.recorder-btn {
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.15);
    color: #f87171;
}
.recorder-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.recorder-active {
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.recording-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    animation: recording-pulse 1s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

@keyframes recording-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.8); }
}

.recorder-stop-btn {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.recorder-stop-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

/* Responsive adjustments for recorder */
@media (max-width: 480px) {
    .recorder-active {
        padding: 0.75rem !important;
        gap: 0.5rem !important;
    }
    .recorder-active .flex {
        gap: 0.5rem !important;
    }
    #recorderStatusText,
    .recorder-stop-btn .btn-text {
        display: none !important;
    }
    .recorder-stop-btn {
        padding: 0.5rem !important;
        width: 2.25rem;
        height: 2.25rem;
        justify-content: center;
        border-radius: 50% !important;
        flex-shrink: 0;
    }
    .recorder-stop-btn i {
        font-size: 0.75rem !important;
    }
}

/* Pause button */
.recorder-pause-btn {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}
.recorder-pause-btn:hover {
    background: rgba(251, 191, 36, 0.18);
    border-color: rgba(251, 191, 36, 0.35);
}

/* Paused state */
.recording-dot.paused {
    animation: none;
    opacity: 0.5;
    background: #fbbf24;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
}

/* ===== Audio Player ===== */
.audio-player {
    border-radius: 8px;
    height: 36px;
    color-scheme: dark;
}

.audio-speed-btn {
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.15);
    color: var(--accent-bright);
    border-radius: 9999px;
    padding: 3px 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}
.audio-speed-btn:hover {
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.3);
}

/* ===== Media Preview ===== */
#mediaPreviewContent img {
    max-height: 200px;
    width: 100%;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

#mediaPreviewContent video {
    max-height: 200px;
    width: 100%;
    border-radius: 8px;
    color-scheme: dark;
}

#mediaPreviewContent audio {
    width: 100%;
    height: 36px;
    color-scheme: dark;
}
