/* Modern Color Palette */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #0ea5e9;
    --accent: #f472b6;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius: 0.75rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Login Page Specifics */
    --login-bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-image: radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* Glassmorphism Header */
.main-header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 1rem 0;
    box-shadow: var(--shadow-sm);
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

.logo span {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

nav a:hover {
    color: var(--primary);
    background-color: rgba(79, 70, 229, 0.05);
}

.btn-login {
    background: var(--primary);
    color: white !important;
    padding: 0.5rem 1.25rem;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn-login:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* Modern Forms & Cards */
.form-card {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    margin-bottom: 3rem;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h2 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.925rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
textarea,
select,
input[type="file"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s;
    background-color: #f8fafc;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-light);
    background-color: white;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

button[type="submit"] {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    font-size: 1rem;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
    margin-top: 1rem;
}

button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(79, 70, 229, 0.3);
}

/* Status Badges */
.status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.status-Recibido {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.status-En-Proceso {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.status-Observado {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.status-Finalizado {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    font-weight: 500;
    border-left: 4px solid transparent;
}

.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border-left-color: #10b981;
}

.alert-error {
    background-color: #fef2f2;
    color: #991b1b;
    border-left-color: #ef4444;
}

/* Footer */
.main-footer {
    margin-top: auto;
    background-color: white;
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    color: var(--text-main);
    font-size: 0.95rem;
}

tr:last-child td {
    border-bottom: none;
}

/* Page Specific: Login */
body.page-login {
    align-items: center;
    justify-content: center;
    background-image: var(--login-bg-gradient);
}

.login-card {
    background: var(--surface);
    padding: 3rem;
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-header h1 {
    font-size: 1.75rem;
    margin-bottom: 2rem;
    color: var(--text-main);
}

.btn-back {
    display: inline-block;
    margin-top: 1.5rem;
    color: white;
    font-weight: 500;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.btn-back:hover {
    opacity: 1;
}

/* Admin Layout with Sidebar */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 280px;
    /* Slightly wider for better breathing room */
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
    /* Very subtle depth */
    text-align: left;
}

.admin-sidebar-header {
    padding: 2rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    width: 100%;
}

.admin-logo-text {
    font-weight: 800;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
    text-align: left;
}

.admin-sidebar-nav {
    padding: 1.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    /* Tighter gap for grouped feel */
    flex: 1;
    overflow-y: auto;
    width: 100%;
    align-items: stretch;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 0.875rem;
    padding: 0.75rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.925rem;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
    border: none;
    width: 100%;
}

.nav-link:hover {
    background: #f1f5f9;
    color: var(--text-main);
    transform: translateX(4px);
}

.nav-link.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3), 0 2px 4px -1px rgba(79, 70, 229, 0.15);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.nav-link:hover svg {
    opacity: 1;
}

.nav-link.active svg {
    opacity: 1;
    stroke-width: 2px;
}

.admin-user-profile {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #f8fafc;
    /* Subtle contrast for footer area */
}

.admin-main {
    flex: 1;
    margin-left: 280px;
    /* Width of sidebar */
    background: var(--background);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: flex-end;
    position: sticky;
    top: 0;
    z-index: 40;
}

/* Mobile Sidebar logic */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .admin-main {
        margin-left: 0;
    }
}

/* Legacy admin-nav hidden just in case */
.admin-nav {
    display: none;
}

/* Admin Dashboard Grid */
.dashboard-grid {
    display: grid;
    /* Force 4 columns on desktop as requested */
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card .value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

/* Responsive Utilities */
.mobile-only {
    display: none;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.form-card .table-responsive {
    border: none;
    margin-bottom: 0;
}

.table-responsive table {
    margin-bottom: 0;
}

.table-responsive td,
.table-responsive th {
    white-space: nowrap;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile Media Query Enhancements */
@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }

    .container {
        padding: 0 1rem;
    }

    /* Public Header Mobile */
    /* Public Header Mobile */
    .btn-login {
        display: block;
        /* Show it in the menu */
        background-color: var(--primary) !important;
        /* Force blue background */
        color: white !important;
        text-align: center;
        margin-top: 0.5rem;
    }

    .mobile-menu-toggle {
        background: none;
        border: none;
        color: var(--text-main);
        padding: 0.5rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        width: 40px;
        height: 40px;
    }

    .mobile-menu-toggle svg {
        width: 24px;
        height: 24px;
    }

    .main-header nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 1rem;
        gap: 0.5rem;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        transform: translateY(-10px);
        opacity: 0;
        pointer-events: none;
        transition: all 0.2s ease;
    }

    .main-header nav.active {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .main-header nav a {
        display: block;
        width: 100%;
        padding: 0.75rem 1rem;
        background: #f8fafc;
        border-radius: 0.5rem;
    }

    .main-header nav a:hover {
        background: #f1f5f9;
    }

    /* Admin Sidebar Mobile Adjustment causes overlap if not handled */
    .admin-sidebar {
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
    }

    /* Top Bar Mobile */
    .top-bar {
        padding: 0.75rem 1rem;
        justify-content: space-between;
    }

    /* Compact Form Cards Mobile */
    .form-card {
        padding: 1rem;
        margin-bottom: 2rem;
    }

    h2 {
        font-size: 1.25rem;
        /* Smaller heading */
        margin-bottom: 1.5rem;
    }

    /* Compact Stat Cards */
    .stat-card {
        padding: 1rem;
    }

    .stat-card h3 {
        font-size: 0.75rem;
    }

    .stat-card .value {
        font-size: 1.75rem;
        /* Smaller number */
    }

    /* Login Mobile */
    .login-card {
        padding: 1.5rem;
        margin: 1rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }
}