/* ─────────────────────────────────────────────
   Test OCR – Global Styles
───────────────────────────────────────────── */
:root {
    --bg-primary:    #111111;
    --bg-secondary:  #1A1A1A;
    --bg-card:       #212121;
    --bg-card-hover: #2C2C2C;
    --accent:        #FF6900;
    --accent-light:  #FF9E66;
    --accent-teal:   #FF7A1A;
    --accent-purple: #FF9E66;
    --text-primary:  #EDEDED;
    --text-muted:    #8A8A8A;
    --border:        rgba(255,255,255,.08);
    --sidebar-w:     240px;
    --topbar-h:      64px;
    --radius:        14px;
    --shadow:        0 8px 32px rgba(0,0,0,.5);
    --transition:    .2s ease;

    /* Semánticos */
    --color-error:   #D32F2F;
    --color-success: #388E3C;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── SIDEBAR ─────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transition: width var(--transition);
    z-index: 100;
}
.sidebar.collapsed { width: 68px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-nav span,
.sidebar.collapsed .sidebar-footer { display: none; }
.sidebar.collapsed .nav-icon { margin-right: 0; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 18px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-teal));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    padding: 5px;
    box-shadow: 0 0 12px rgba(255,105,0,.4);
}
.sidebar-brand .brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}
.brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    background: linear-gradient(135deg, var(--accent), var(--accent-teal));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    list-style: none;
}
.sidebar-nav li {
    list-style: none;
    padding: 0;
    margin: 0;
}
.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: .93rem;
    transition: all var(--transition);
}
.nav-item { color: rgba(255,255,255,.6); }
.nav-item:hover { background: rgba(255,255,255,.08); color: #FFFFFF; }
.nav-item.active {
    background: linear-gradient(135deg, rgba(255,105,0,.35), rgba(255,158,102,.2));
    color: #FFFFFF;
    border: 1px solid rgba(255,105,0,.5);
}
.nav-icon { font-size: 1rem; min-width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.1);
    color: rgba(255,255,255,.4);
    font-size: .78rem;
}

/* ── MAIN CONTENT ────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
    min-height: 100vh;
}
.main-content.expanded { margin-left: 68px; }

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(0,0,0,.15);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    color: rgba(255,255,255,.85);
}
.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all var(--transition);
}
.sidebar-toggle:hover { background: rgba(255,255,255,.1); color: #FFFFFF; }
.topbar-title { font-weight: 600; font-size: 1.05rem; color: #FFFFFF; }
.topbar-right { margin-left: auto; }
.badge-status {
    font-size: .82rem;
    color: var(--text-muted);
}

/* Content area */
.content-area { padding: 28px 28px; flex: 1; }

/* ── STAT CARDS ──────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    flex-shrink: 0;
}
.stat-icon.bg-purple { background: linear-gradient(135deg, #FF6900, #FF9E66); }
.stat-icon.bg-teal   { background: linear-gradient(135deg, #e05a00, #FF6900); }
.stat-label { font-size: .82rem; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 1.7rem; font-weight: 700; }

/* ── CUSTOM CARDS ────────────────────────── */
.card-custom {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.card-custom-header {
    padding: 16px 20px;
    background: rgba(255,255,255,.03);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .96rem;
    display: flex;
    align-items: center;
}
.card-custom-body {
    padding: 20px;
    flex: 1;
}

/* ── DARK TABLE ──────────────────────────── */
.table-dark-custom {
    color: var(--text-primary);
}
.table-dark-custom thead th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: .82rem;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 10px 12px;
}
.table-dark-custom tbody td {
    border-top: 1px solid var(--border);
    padding: 10px 12px;
    font-size: .9rem;
    vertical-align: middle;
}
.table-dark-custom tbody tr:hover td { background: rgba(255,105,0,.1); }

/* ── DROP ZONE ───────────────────────────── */
.drop-zone {
    border: 2px dashed rgba(255,105,0,.4);
    border-radius: var(--radius);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: rgba(255,105,0,.04);
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(255,105,0,.1);
}
.drop-icon { font-size: 2.8rem; color: var(--accent); margin-bottom: 12px; }
.drop-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.drop-sub { font-size: .85rem; color: var(--text-muted); }

.img-preview {
    max-width: 100%;
    max-height: 260px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* ── RESULTADO OCR ───────────────────────── */
.resultado-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.resultado-stats .badge { font-size: .82rem; padding: 5px 10px; border-radius: 20px; }

.texto-completo {
    background: rgba(0,0,0,.25);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: .88rem;
    line-height: 1.7;
    max-height: 260px;
    overflow-y: auto;
    white-space: pre-wrap;
    color: var(--accent-teal);
}

/* confianza colores */
.conf-high { color: #4ade80; }
.conf-med  { color: #facc15; }
.conf-low  { color: #f87171; }

/* ── TOAST ALERTAS ───────────────────────── */
.toast-alert {
    position: fixed;
    bottom: 24px; right: 24px;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 500;
    z-index: 9999;
    box-shadow: var(--shadow);
    max-width: 380px;
}
.toast-success { background: rgba(74,222,128,.15); border: 1px solid rgba(74,222,128,.4); color: #4ade80; }
.toast-error   { background: rgba(248,113,113,.15); border: 1px solid rgba(248,113,113,.4); color: #f87171; }
.fade-in { animation: fadeInUp .3s ease forwards; }
@keyframes fadeInUp {
    from { opacity:0; transform:translateY(16px); }
    to   { opacity:1; transform:translateY(0); }
}

/* ── INPUTS / FORM CONTROLS ─────────────── */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]),
select,
textarea,
.form-control,
.form-select {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]):focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-select:focus {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(255,105,0,.2) !important;
    outline: none !important;
}
input::placeholder,
textarea::placeholder,
.form-control::placeholder { color: var(--text-muted) !important; }
select option { background: var(--bg-secondary); color: var(--text-primary); }
.form-label,
label { color: var(--text-muted); font-size: .88rem; font-weight: 500; }

/* ── USER MENU (topbar) ──────────────────── */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px 6px 6px;
    border-radius: 40px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: background var(--transition), border-color var(--transition);
    user-select: none;
}

.user-menu:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255,105,0,.35);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,105,0,.5);
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.user-name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: .72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.user-chevron {
    font-size: .7rem;
    color: var(--text-muted);
    transition: transform var(--transition);
    flex-shrink: 0;
}

.user-menu.open .user-chevron {
    transform: rotate(180deg);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 9999;
    overflow: hidden;
    animation: fadeInUp .18s ease forwards;
}

.user-menu.open .user-dropdown { display: block; }

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    font-size: .87rem;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.user-dropdown-item:hover {
    background: rgba(255,105,0,.1);
    color: var(--accent);
}

.user-dropdown-item i { font-size: .85rem; width: 16px; text-align: center; }

.user-dropdown-item--danger { color: #f87171; }
.user-dropdown-item--danger:hover { background: rgba(248,113,113,.1); color: #f87171; }

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 2px 0;
}

/* ── NAV GROUP ──────────────────────────── */
.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: rgba(255,255,255,.6);
    text-decoration: none;
    font-weight: 500;
    font-size: .93rem;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
}
.nav-group-toggle:hover { background: rgba(255,255,255,.08); color: #FFFFFF; }
.nav-group-chevron { margin-left: auto; font-size: .75rem; transition: transform var(--transition); }
.nav-group-toggle[aria-expanded="true"] .nav-group-chevron { transform: rotate(180deg); }
.nav-group-submenu { padding-left: 8px; }

/* ── SIDEBAR OVERLAY (mobile) ────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 99;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── RESPONSIVE ──────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition);
        z-index: 100;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-w);
    }
    .main-content {
        margin-left: 0 !important;
    }
    .main-content.expanded {
        margin-left: 0 !important;
    }
    .topbar {
        padding: 0 16px;
    }
    .topbar-title {
        font-size: .92rem;
    }
    .user-name {
        max-width: 100px;
    }
    .content-area {
        padding: 16px;
    }
}

/* ── SCROLLBAR ───────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,105,0,.6); }
