/* ============================================
   Sistema de Correspondencia DCICE
   Premium Dark Government Theme
   ============================================ */

/* ---- CSS Variables ---- */
:root {
    /* Colors - Dark Government Theme */
    --bg-dark: #0f1117;
    --bg-card: #1a1e2e;
    --bg-card-hover: #1f2438;
    --bg-sidebar: #141827;
    --bg-input: #252a3a;
    --bg-modal: #1e2235;

    /* Accent colors */
    --primary: #6c5ce7;
    --primary-light: #a29bfe;
    --primary-dark: #5a4bd1;
    --primary-glow: rgba(108, 92, 231, 0.15);

    --accent-green: #00b894;
    --accent-blue: #0984e3;
    --accent-orange: #e17055;
    --accent-yellow: #fdcb6e;
    --accent-red: #ff6b6b;
    --accent-teal: #00cec9;
    --accent-purple: #a29bfe;

    /* Text */
    --text-primary: #e8eaf0;
    --text-secondary: #a0a4b8;
    --text-muted: #6b7089;
    --text-white: #ffffff;

    /* Borders */
    --border: #2a2e42;
    --border-light: #353a52;
    --border-focus: #6c5ce7;

    /* Status colors */
    --status-recibido: #74b9ff;
    --status-en-revision: #fdcb6e;
    --status-turnado: #a29bfe;
    --status-en-proceso: #00cec9;
    --status-atendido: #00b894;
    --status-archivado: #636e72;

    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    /* Shadows */
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px var(--primary-glow);
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a {
    color: var(--primary-light);
    text-decoration: none;
}

a:hover {
    color: var(--primary);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-info {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
}

.sidebar-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-glow);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.logo-title {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
    letter-spacing: -0.02em;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    font-size: 0.92rem;
}

.nav-item:hover {
    background: rgba(108, 92, 231, 0.1);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary-light);
    font-weight: 600;
    box-shadow: var(--shadow-glow);
}

.nav-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* Footer */
.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 4px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
    flex-shrink: 0;
}

.user-name {
    font-weight: 600;
    font-size: 0.85rem;
    display: block;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
    text-transform: capitalize;
}

.logout-btn {
    color: var(--accent-red) !important;
}

.logout-btn:hover {
    background: rgba(255, 107, 107, 0.1) !important;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed);
}

/* Header */
.main-header {
    height: var(--header-height);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 6px;
}

.hamburger span {
    width: 22px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: 0.3s;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-sync {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-sync:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-sync:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Page Content */
.page-content {
    padding: 24px 28px;
    max-width: 1400px;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.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: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.stat-total::before {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.stat-pending::before {
    background: linear-gradient(90deg, var(--accent-yellow), var(--accent-orange));
}

.stat-urgent::before {
    background: linear-gradient(90deg, var(--accent-red), #e74c3c);
}

.stat-today::before {
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-teal));
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 2rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    display: block;
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */
.dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.full-width {
    grid-column: 1 / -1;
}

/* Gmail Status */
.gmail-connected,
.gmail-disconnected {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.gmail-disconnected-info {
    text-align: center;
    padding: 20px;
}

.gmail-disconnected-info p {
    margin-bottom: 12px;
}

.gmail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.gmail-stat {
    text-align: center;
    padding: 12px 8px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.gmail-stat-num {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-light);
}

.gmail-stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text-primary);
    font-size: inherit;
    font-family: inherit;
}

.quick-action:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    transform: translateY(-2px);
    color: var(--text-primary);
}

.qa-icon {
    font-size: 1.5rem;
}

.qa-label {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Department Overview */
.dept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.dept-card {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    transition: transform 0.2s;
}

.dept-card:hover {
    transform: translateX(4px);
}

.dept-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.dept-icon {
    font-size: 1.2rem;
}

.dept-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.dept-card-stats {
    display: flex;
    gap: 16px;
}

.dept-stat {
    text-align: center;
}

.dept-stat-num {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dept-stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ============================================
   CORRESPONDENCE LIST
   ============================================ */
.corr-list {
    display: flex;
    flex-direction: column;
}

.corr-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    color: var(--text-primary);
    text-decoration: none;
    gap: 12px;
}

.corr-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.corr-item:last-child {
    border-bottom: none;
}

.corr-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.corr-item-main {
    min-width: 0;
    flex: 1;
}

.corr-priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.priority-normal {
    background: var(--accent-green);
}

.priority-urgente {
    background: var(--accent-yellow);
}

.priority-muy_urgente {
    background: var(--accent-red);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.corr-subject {
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.corr-sender {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.corr-item-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.corr-status {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.corr-date {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.corr-dept-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
    white-space: nowrap;
}

.corr-folio {
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    color: var(--primary-light);
    font-weight: 600;
}

/* Overdue */
.corr-item.overdue {
    background: rgba(255, 107, 107, 0.05);
}

.corr-item.overdue .corr-due {
    color: var(--accent-red);
    font-weight: 600;
    font-size: 0.72rem;
}

/* ============================================
   FILTERS BAR
   ============================================ */
.filters-bar {
    margin-bottom: 20px;
}

.filters-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 220px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.filter-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 9px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s;
    min-width: 140px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Status Pills */
.status-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.status-pill {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-pill:hover {
    border-color: var(--pill-color, var(--primary));
    color: var(--text-primary);
}

.status-pill.active {
    background: var(--pill-color, var(--primary));
    color: white;
    border-color: var(--pill-color, var(--primary));
}

.pill-count {
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.8;
}

/* ============================================
   TABLE
   ============================================ */
.table-responsive {
    overflow-x: auto;
}

.table-card {
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table td {
    padding: 12px 16px;
    font-size: 0.85rem;
    vertical-align: middle;
}

.th-priority {
    width: 30px;
}

.td-priority {
    text-align: center;
    width: 30px;
}

.folio-badge {
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-light);
    background: var(--primary-glow);
    padding: 2px 8px;
    border-radius: 4px;
}

.subject-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.subject-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.attachment-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sender-cell {
    min-width: 0;
}

.sender-name {
    display: block;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sender-inst {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dept-badge {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-badge {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.td-date {
    color: var(--text-muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

.table-footer {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
}

.table-info {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.pagination {
    display: flex;
    gap: 4px;
}

.page-btn {
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Loading */
.loading-row td {
    padding: 48px 20px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.empty-row td {
    padding: 48px 20px;
}

/* ============================================
   DETAIL PAGE
   ============================================ */
.detail-layout {
    max-width: 1200px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--primary-light);
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb-sep {
    color: var(--text-muted);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

.detail-header-card .card-body {
    padding: 0;
}

.detail-header-card {
    padding: 24px;
}

.detail-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.detail-title-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.detail-folio {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-light);
    background: var(--primary-glow);
    padding: 3px 10px;
    border-radius: 4px;
}

.detail-type {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.detail-status {
    font-size: 0.82rem;
    padding: 5px 16px;
    border-radius: 16px;
    font-weight: 600;
}

.detail-subject {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.4;
}

.detail-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.meta-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.meta-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.meta-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.meta-value {
    display: block;
    font-size: 0.88rem;
    font-weight: 500;
    margin-top: 2px;
}

.email-body {
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-secondary);
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Response Notes */
.response-notes {
    padding: 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    border-left: 3px solid var(--accent-green);
    font-size: 0.88rem;
    line-height: 1.5;
}

.notes-author {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.notes-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Sidebar Actions */
.detail-sidebar .card {
    margin-bottom: 16px;
}

.action-group {
    margin-bottom: 14px;
}

.action-group:last-child {
    margin-bottom: 0;
}

.action-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Assignments */
.assignments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.assignment-item {
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.assignment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.assignment-status {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--primary-glow);
    color: var(--primary-light);
}

.assignment-instructions {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.assignment-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Activity Timeline */
.activity-timeline {
    display: flex;
    flex-direction: column;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 4px;
    flex-shrink: 0;
}

.timeline-content {
    min-width: 0;
}

.timeline-action {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
}

.timeline-user {
    display: block;
    color: var(--text-muted);
}

.timeline-time {
    display: block;
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* Attachments */
.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.attachment-name {
    font-weight: 500;
    flex: 1;
}

.attachment-size {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #e74c3c);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.72rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 0.95rem;
}

.btn-block {
    width: 100%;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-row {
    display: flex;
    gap: 14px;
}

.form-control {
    width: 100%;
    /* Aumentamos el padding izquierdo a 45px para que el texto no choque con el icono */
    padding: 12px 14px 12px 45px !important;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.input-icon-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
    padding: 20px;
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
}

.alert-error {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.2);
    color: var(--accent-red);
}

.alert-success {
    background: rgba(0, 184, 148, 0.1);
    border: 1px solid rgba(0, 184, 148, 0.2);
    color: var(--accent-green);
}

/* ============================================
   TOASTS
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 420px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: all;
}

.toast.show {
    transform: translateX(0);
}

.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    font-size: 0.85rem;
}

.toast-success {
    border-left: 3px solid var(--accent-green);
}

.toast-error {
    border-left: 3px solid var(--accent-red);
}

.toast-warning {
    border-left: 3px solid var(--accent-yellow);
}

.toast-info {
    border-left: 3px solid var(--accent-blue);
}

/* ============================================
   STATUS DOTS
   ============================================ */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-active {
    background: var(--accent-green);
    box-shadow: 0 0 6px rgba(0, 184, 148, 0.4);
}

.status-inactive {
    background: var(--accent-red);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-danger {
    background: rgba(255, 107, 107, 0.15);
    color: var(--accent-red);
}

.badge-success {
    background: rgba(0, 184, 148, 0.15);
    color: var(--accent-green);
}

/* Role badges */
.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
}

.role-admin {
    background: rgba(108, 92, 231, 0.15);
    color: var(--primary-light);
}

.role-jefe_depto {
    background: rgba(0, 184, 148, 0.15);
    color: var(--accent-green);
}

.role-operador {
    background: rgba(9, 132, 227, 0.15);
    color: var(--accent-blue);
}

.role-viewer {
    background: rgba(99, 110, 114, 0.15);
    color: var(--text-muted);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
}

.empty-state p {
    margin-bottom: 16px;
}

/* ============================================
   TEXT UTILITIES
   ============================================ */
.text-muted {
    color: var(--text-muted) !important;
}

.text-danger {
    color: var(--accent-red) !important;
}

.text-warning {
    color: var(--accent-yellow) !important;
}

.text-success {
    color: var(--accent-green) !important;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-dark);
    width: 100%;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 184, 148, 0.05) 0%, transparent 50%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    font-size: 40px;
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--primary-glow);
    border-radius: var(--radius);
}

.login-logo h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.login-logo p {
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.login-subtitle {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ============================================
   SETTINGS
   ============================================ */
.settings-card {
    margin-bottom: 24px;
}

.settings-form {
    max-width: 480px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.connection-details {
    margin-bottom: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.connection-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.gmail-connected-info,
.gmail-disconnected-info {
    padding: 8px 0;
}

/* ============================================
   CHART
   ============================================ */
.chart-card canvas {
    width: 100% !important;
    height: 200px;
    display: block;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-collapsed);
        transform: translateX(-100%);
    }

    .sidebar.collapsed {
        transform: translateX(0);
        width: var(--sidebar-width);
    }

    .main-content {
        margin-left: 0;
    }

    .main-content.expanded {
        margin-left: 0;
    }

    .hamburger {
        display: flex;
    }

    .page-content {
        padding: 16px;
    }

    .main-header {
        padding: 0 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-wrap: wrap;
    }

    .filter-select {
        min-width: auto;
        flex: 1;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table td,
    .data-table th {
        padding: 10px 12px;
    }

    .subject-text {
        max-width: 180px;
    }

    .dept-grid {
        grid-template-columns: 1fr;
    }

    .detail-meta-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }

    .stat-number {
        font-size: 1.4rem;
    }

    .login-card {
        padding: 30px 24px;
    }

    .modal {
        margin: 10px;
    }

    .modal-body {
        padding: 16px;
    }
}