/* 
   SGPC - Premium Design System
   Modern, Clean, and Responsive
*/

:root {
    --primary: #b0c4de;
    --primary-gradient: linear-gradient(135deg, #b0c4de 0%, #4682b4 100%);
    --primary-hover: #98adc7;
    --secondary: #64748b;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 4px 8px -1px rgba(0, 0, 0, 0.12), 0 2px 4px -2px rgba(0, 0, 0, 0.08);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
/* Sidebar Container */
.sidebar {
    width: 260px;
    background: #d8e5f2; /* Soft pastel slate blue matching reference design */
    color: #1e3b85;
    padding: 0;
    position: fixed;
    height: 100vh;
    transition: all 0.3s ease;
    overflow: hidden;
    border-right: 1px solid #b2c6de;
    display: flex;
    flex-direction: column;
    z-index: 99;
}

/* Fixed Header with Logo */
.sidebar-header {
    flex-shrink: 0;
    height: 130px;
    box-sizing: border-box;
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    padding: 0.75rem 0.75rem;
    color: #1b3b85;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #d8e5f2;
    z-index: 10;
    border-bottom: 1px solid #b2c6de;
}

.sidebar-header img {
    width: 100%;
    max-width: 240px;
    height: auto;
    max-height: 110px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    border-radius: 6px;
}

/* Scrollable Menu Items Container */
.nav-links {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.75rem 2rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

/* Custom Scrollbar for Nav Links */
.nav-links::-webkit-scrollbar {
    width: 5px;
}
.nav-links::-webkit-scrollbar-track {
    background: #d8e5f2;
}
.nav-links::-webkit-scrollbar-thumb {
    background: #a9c2df;
    border-radius: 10px;
}
.nav-links::-webkit-scrollbar-thumb:hover {
    background: #8aaad0;
}

/* Single Direct Links (e.g. Dashboard) */
.nav-direct-link {
    color: #1b3b85;
    text-decoration: none;
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}
.nav-direct-link:hover {
    background: #c5d9ed;
    color: #152c67;
}
.nav-direct-link.active {
    background: #b6d0ea;
    color: #152c67;
    font-weight: 700;
}

/* Category Accordion Buttons */
.nav-category-group {
    display: flex;
    flex-direction: column;
}

.nav-category-btn {
    width: 100%;
    background: transparent;
    border: none;
    color: #1b3b85;
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: left;
}

.nav-category-btn:hover {
    background: #c5d9ed;
    color: #152c67;
}

.nav-category-btn .btn-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-category-btn .chevron-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

/* Expanded Active Category State (Matching Reference Screenshot) */
.nav-category-group.expanded .nav-category-btn {
    background: #1b3b85; /* Deep Navy Blue */
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(27, 59, 133, 0.2);
}

.nav-category-group.expanded .nav-category-btn .chevron-icon {
    transform: rotate(180deg);
}

/* Sub-items Container (Vertical Indicator Line) */
.nav-subgroup {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 1.5rem;
    border-left: 2px solid #a3b8d4; /* Thin vertical indicator line */
    padding-left: 0.4rem;
}

.nav-category-group.expanded .nav-subgroup {
    max-height: 600px;
    margin-top: 0.4rem;
    margin-bottom: 0.4rem;
}

.nav-sublinks {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.2rem 0;
}

.nav-sublink {
    color: #284474;
    text-decoration: none;
    padding: 0.5rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-sublink:hover {
    background: #c5d9ed;
    color: #152c67;
}

/* Active Sub-item Pill (Matching Reference 'Categorias' Pill) */
.nav-sublink.active-subitem {
    background: #b5cee7; /* Light blue rounded pill */
    color: #152c67;
    font-weight: 700;
}

.nav-sublink.restricted {
    opacity: 0.6;
}

.restricted-lock {
    font-size: 0.7rem;
    margin-left: auto;
    color: #64748b;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 3rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    position: sticky;
    top: 130px;
    z-index: 90;
    background: var(--bg-main, #f8fafc);
    padding: 1.5rem 0 1rem 0;
    margin-top: -2rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
}

/* Cards & Components */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1.5px solid var(--border);
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-left: 4px solid #4682b4; /* Accent blue from gradient */
}

.stat-card .label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    height: 44px;
    box-sizing: border-box;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(176, 196, 222, 0.25);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Stacked Buttons Design (Icon on top, Text below) */
.btn-stacked {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    height: 44px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 8px;
    gap: 2px;
    min-width: 80px;
    transition: all 0.2s;
    border: 1.5px solid transparent;
    cursor: pointer;
    text-decoration: none;
    line-height: 1;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-stacked i {
    font-size: 1rem;
}

.btn-stacked.btn-success {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}
.btn-stacked.btn-success:hover {
    background: #bbf7d0;
    transform: translateY(-1px);
}
.btn-stacked.btn-success:disabled,
.btn-stacked.btn-success[disabled] {
    background-color: rgba(220, 252, 231, 0.45) !important;
    color: rgba(22, 101, 52, 0.45) !important;
    border-color: rgba(134, 239, 172, 0.45) !important;
    cursor: not-allowed !important;
    transform: none !important;
    pointer-events: none;
}

.btn-stacked.btn-danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: #f87171;
}
.btn-stacked.btn-danger:hover {
    background: #fecaca;
    transform: translateY(-1px);
}
.btn-stacked.btn-danger:disabled,
.btn-stacked.btn-danger[disabled] {
    background-color: rgba(254, 226, 226, 0.45) !important;
    color: rgba(153, 27, 27, 0.45) !important;
    border-color: rgba(248, 113, 113, 0.45) !important;
    cursor: not-allowed !important;
    transform: none !important;
    pointer-events: none;
}

.btn-stacked.btn-warning {
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}
.btn-stacked.btn-warning:hover {
    background: #fde68a;
    transform: translateY(-1px);
}

.btn-stacked.btn-primary {
    background: #eff6ff;
    color: #1e40af;
    border-color: #93c5fd;
}
.btn-stacked.btn-primary:hover {
    background: #dbeafe;
    transform: translateY(-1px);
}

.btn-stacked.btn-info {
    background: #f8fafc;
    color: #475569;
    border-color: #e2e8f0;
}
.btn-stacked.btn-info:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead tr {
    background: linear-gradient(90deg, rgba(176, 196, 222, 0.25) 0%, rgba(70, 130, 180, 0.15) 100%);
}

.data-table th {
    text-align: left;
    padding: 1rem;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 2px solid var(--border);
    background: transparent;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover {
    background: #f8fafc;
}

/* Badges */
.badge {
    padding: 0 0.8rem;
    height: 44px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.025em;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-success { background-color: var(--success-color); color: #fff; }
.btn-import-ai {
    background: linear-gradient(135deg, #58d68d 0%, #2ecc71 100%) !important;
    min-width: 240px;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.2);
    border: none !important;
}
.btn-import-ai:hover {
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
    transform: translateY(-1px);
}
.btn-danger { background-color: var(--danger-color); color: #fff; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* Dashboard Specific */
.activity-list {
    list-style: none;
}

.activity-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.activity-item:last-child {
    border-bottom: none;
}

/* ========================================================================= */
/* Responsive Design (Mobile & Tablet) */
/* ========================================================================= */

.mobile-menu-toggle {
    display: none;
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.25rem;
}

/* Overlay dark background behind sidebar on mobile */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    backdrop-filter: blur(2px);
}
#sidebar-overlay.active {
    display: block;
}

@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        transform: translateX(-100%);
        z-index: 999;
        width: 280px;
        box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 1.5rem 1rem;
        width: 100%;
        overflow-x: hidden;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .user-profile {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .mobile-menu-toggle {
        display: inline-block;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Wrap tables to scroll horizontally on small screens */
    .card {
        padding: 1rem;
        width: 100%;
        overflow-x: auto;
    }

    .data-table {
        min-width: 700px;
    }
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    h1 {
        font-size: 1.5rem;
    }
}

/* Sidebar Collapsibles */
.nav-label {
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s ease;
    padding-right: 1.5rem;
    color: #475569; /* Slate-600 */
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.nav-label:hover {
    opacity: 0.8;
}
.nav-group {
    overflow: hidden;
}
.nav-group.collapse {
    display: none;
}
.nav-group li {
    margin-bottom: 0.5rem;
}
