/* 
   Portal de Empréstimos - UFRB
   Design System: Clean, Acessível, Moderno
*/

:root {
    --primary: #004a87;
    --primary-light: #e0f0ff;
    --primary-dark: #003566;
    --accent: #dc2626;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --info: #2563eb;
    --info-bg: #dbeafe;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-alt: #f8fafc;
    --text-main: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px rgb(0 0 0 / 0.1), 0 1px 2px rgb(0 0 0 / 0.06);
    --shadow-md: 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);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 200ms ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== SKIP LINK (Accessibility) ========== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    z-index: 1000;
    font-weight: 600;
    text-decoration: none;
}
.skip-link:focus {
    top: 0.5rem;
}

/* ========== LAYOUT ========== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* ========== HEADER ========== */
header {
    background: var(--bg-card);
    border-bottom: 3px solid var(--primary);
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 64px;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}
.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}
.logo-group h1 {
    font-size: 1.125rem;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: -0.25px;
    line-height: 1.1;
}
.logo-group p {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.125rem;
}

/* ========== NAVIGATION ========== */
nav ul {
    list-style: none;
    display: flex;
    gap: 0.125rem;
    flex-wrap: wrap;
}

nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius);
    transition: all var(--transition);
    display: block;
    white-space: nowrap;
}
nav a:hover {
    background: var(--primary-light);
    color: var(--primary);
}
nav a.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 74, 135, 0.2);
}
nav a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.user-info {
    text-align: right;
}
.user-name {
    font-weight: 600;
    font-size: 0.8125rem;
    display: block;
    line-height: 1.2;
}
.user-unit {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: block;
}
.unit-select {
    border: none;
    background: var(--bg-alt);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
}
.unit-select:hover {
    background: var(--primary-light);
}
.logout-link {
    color: var(--text-muted);
    background: var(--bg-alt);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    border: 1px solid var(--border);
}
.logout-link:hover {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #fecaca;
}

/* ========== CARDS ========== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin: 0 auto;
    transition: box-shadow var(--transition);
}
.card:hover {
    box-shadow: var(--shadow-md);
}

/* ========== STAT CARDS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
    margin-top: 0.25rem;
}
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.success .stat-value { color: var(--success); }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    border: 1px solid transparent;
    line-height: 1.4;
}
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
}
.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-outline {
    border-color: var(--border-hover);
    color: var(--text-secondary);
    background: var(--bg-card);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: var(--text-main);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-main);
    background: var(--bg-card);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 74, 135, 0.15);
}
.form-group input::placeholder {
    color: var(--text-muted);
}
.form-group small, .form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* Checkbox/Toggle styles */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 0;
}
.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

/* ========== DATA TABLES ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}
.data-table th {
    background: var(--bg-alt);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table tbody tr {
    transition: background var(--transition);
}
.data-table tbody tr:hover {
    background: var(--bg-alt);
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.25px;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: #15803d; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-danger  { background: var(--danger-bg); color: #991b1b; }
.badge-info    { background: var(--info-bg); color: #1d4ed8; }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-bem     { background: #e0f2fe; color: #0369a1; }
.badge-material { background: #fef9c3; color: #854d0e; }

/* ========== ALERTS ========== */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-danger  { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--success-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert-info    { background: var(--info-bg); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: var(--warning-bg); color: #854d0e; border: 1px solid #fde68a; }

/* ========== SECTION HEADERS ========== */
.page-header {
    margin-bottom: 2rem;
}
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}
.page-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ========== FILTER BAR ========== */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.filter-bar form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}
.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

/* ========== FOOTER ========== */
footer {
    text-align: center;
    padding: 1.5rem 2rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    margin-top: auto;
}

/* ========== LOGIN PAGE ========== */
.login-wrapper {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, #1a6bbf 100%);
    padding: 2rem;
    z-index: 9999;
    overflow-y: auto;
}
.login-container {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 850px;
    overflow: hidden;
    min-height: 500px;
}

/* Lado Administrativo */
.login-side-admin {
    flex: 1;
    padding: 2.5rem;
    border-right: 1px solid var(--border);
}
.login-side-admin h2 {
    color: var(--primary);
    text-align: center;
    margin-bottom: 0.25rem;
    font-size: 1.375rem;
}
.login-side-admin .login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-bottom: 2rem;
}

/* Lado de Reserva Pública */
.login-side-public {
    flex: 1;
    padding: 2.5rem;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.login-side-public::before {
    content: '';
    position: absolute;
    top: -20%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: var(--primary-light);
    border-radius: 50%;
    opacity: 0.3;
}
.public-content {
    position: relative;
    z-index: 1;
}
.public-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
}
.public-title {
    color: var(--primary-dark);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}
.public-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    max-width: 280px;
}
.btn-public {
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius);
    transition: all var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-public:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
    .login-wrapper {
        align-items: flex-start;
    }
    .login-container {
        flex-direction: column;
        max-width: 420px;
    }
    .login-side-admin {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .login-side-public {
        padding: 2rem;
    }
}

/* ========== PRINT ========== */
@media print {
    header, nav, footer, .container > *:not(#pdf_preview),
    .filter-bar, .btn, .stats-grid, .page-header,
    .card:not(#pdf_preview) {
        display: none !important;
    }
    #pdf_preview {
        display: block !important;
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 2cm !important;
        position: static !important;
    }
    #pdf_preview .btn {
        display: none !important;
    }
    body {
        background: #fff !important;
    }
}

/* ========== DASHBOARD SPECIFIC ========== */
.dashboard-hero {
    background: linear-gradient(100deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.dashboard-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}
.dashboard-hero h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.dashboard-hero p {
    opacity: 0.9;
    font-size: 1rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-icon.neutral { background: #f1f5f9; color: var(--text-secondary); }

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}
.section-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}
.text-link {
    color: var(--primary);
    font-size: 0.875rem;
    text-decoration: none;
    font-weight: 500;
}
.text-link:hover {
    text-decoration: underline;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.action-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}
.action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}
.action-card .action-icon {
    font-size: 1.5rem;
    width: 42px;
    height: 42px;
    background: var(--bg-alt);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.action-card span {
    font-size: 0.8125rem;
    font-weight: 600;
}

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.data-table {
    border: none;
    box-shadow: none;
    border-radius: 0;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    nav ul {
        gap: 0.125rem;
        justify-content: center;
    }
    nav a {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
    .container {
        padding: 1rem;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .filter-bar form {
        flex-direction: column;
    }
    .dashboard-hero {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
    .quick-actions-grid {
        grid-template-columns: 1fr 1fr;
    }
}
