/* ==========================================================================
   HRMO Incoming Communication & Document Tracking Management System
   City of Dasmariñas, Cavite
   Custom Stylesheet & UI Components
   ========================================================================== */

:root {
    /* Official City of Dasmariñas & LGU Color Scheme */
    --primary-color: #004d25; /* Official Deep Emerald Green of City of Dasmariñas */
    --primary-hover: #003619;
    --primary-dark: #002310;
    --gov-navy: #0b2545;      /* Philippine LGU Government Navy Blue */
    --gov-navy-dark: #07172b;
    --accent-gold: #d4af37;   /* Official City Gold */
    --accent-gold-hover: #b89528;
    --accent-yellow: #ffc72c;
    --secondary-color: #5d7568;
    --light-bg: #f2f6f3;
    --dark-bg: #091a13;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 64px;
    --card-shadow: 0 4px 14px rgba(0, 77, 37, 0.07);
    --hover-shadow: 0 8px 24px rgba(0, 77, 37, 0.14);
    --border-color: #dbe4de;
    --text-muted: #617369;
    --text-heading: #0e291b;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Status Colors */
    --status-received: #2563eb;
    --status-review: #7c3aed;
    --status-processing: #d97706;
    --status-pending: #db2777;
    --status-completed: #059669;
    --status-archived: #64748b;
    --status-urgent: #dc2626;
}

[data-bs-theme="dark"] {
    --light-bg: #0f172a;
    --text-heading: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body {
    font-family: var(--font-sans);
    background-color: var(--light-bg);
    color: var(--text-heading);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ==========================================================================
   Layout Architecture: Sidebar & Topbar
   ========================================================================== */

#wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    min-height: 100vh;
}

/* Sidebar Styling */
#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: 100vh;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    align-self: flex-start;
    background: linear-gradient(180deg, #004d25 0%, #003318 65%, #0b2545 100%);
    color: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.12);
    border-right: 1px solid rgba(212, 175, 55, 0.25);
}

#sidebar.collapsed {
    min-width: var(--sidebar-collapsed-width);
    max-width: var(--sidebar-collapsed-width);
}

#sidebar .sidebar-header {
    padding: 1.25rem 1.2rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Official Logo Seal Icons */
.seal-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(212, 175, 55, 0.5);
    border: 2px solid var(--accent-gold);
}

.sidebar-seal-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.topbar-seal-img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.topbar-lgu-subtitle {
    font-size: 0.72rem;
    color: var(--primary-color);
    font-weight: 600;
    letter-spacing: 0.5px;
}

#sidebar .sidebar-brand-text {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
}

#sidebar .sidebar-brand-text small {
    display: block;
    font-size: 0.7rem;
    color: var(--accent-gold);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#sidebar .nav-menu {
    padding: 1rem 0.75rem;
    flex-grow: 1;
    overflow-y: auto;
}

#sidebar .nav-item {
    margin-bottom: 0.35rem;
}

#sidebar .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

#sidebar .nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(3px);
}

#sidebar .nav-link.active {
    color: #0b2545;
    background: var(--accent-gold);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

#sidebar .nav-link i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

#sidebar.collapsed .sidebar-brand-text,
#sidebar.collapsed .nav-text,
#sidebar.collapsed .user-info {
    display: none;
}

#sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem 0;
}

#sidebar.collapsed .seal-icon {
    margin: 0 auto;
}

/* User Profile Footer in Sidebar */
#sidebar .sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

#sidebar .user-badge-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#sidebar .user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #ffffff;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    border: 2px solid var(--accent-gold);
    flex-shrink: 0;
}

#sidebar .user-info {
    line-height: 1.2;
    overflow: hidden;
}

#sidebar .user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

#sidebar .user-role {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.65);
}

/* Main Content Area */
#content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top Header Bar */
.topbar {
    height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    position: sticky;
    top: 0;
    z-index: 1030;
}

[data-bs-theme="dark"] .topbar {
    background: #1e293b;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-sidebar-toggle {
    background: transparent;
    border: none;
    font-size: 1.35rem;
    color: var(--text-heading);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-sidebar-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.page-header-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

[data-bs-theme="dark"] .page-header-title {
    color: #f8fafc;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.topbar-search {
    position: relative;
    width: 260px;
}

.topbar-search input {
    padding-left: 2.25rem;
    border-radius: 20px;
    font-size: 0.88rem;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
}

.topbar-search i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Notification Dropdown */
.notif-badge-icon {
    position: relative;
    font-size: 1.3rem;
    color: var(--text-heading);
    cursor: pointer;
    padding: 0.4rem;
}

.notif-badge-icon .badge {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.65rem;
    padding: 0.25em 0.45em;
}

/* ==========================================================================
   UI Cards & Dashboard Widgets
   ========================================================================== */

.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.35rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
}

[data-bs-theme="dark"] .stat-card {
    background: #1e293b;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--hover-shadow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
}

.stat-card.card-primary::before { background: var(--primary-color); }
.stat-card.card-warning::before { background: #f59e0b; }
.stat-card.card-info::before { background: #3b82f6; }
.stat-card.card-success::before { background: #10b981; }
.stat-card.card-danger::before { background: #ef4444; }
.stat-card.card-gold::before { background: var(--accent-gold); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 0.85rem;
}

.stat-icon.icon-primary { background: rgba(11, 37, 69, 0.1); color: var(--primary-color); }
.stat-icon.icon-warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.stat-icon.icon-info { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.stat-icon.icon-success { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.stat-icon.icon-danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.stat-icon.icon-gold { background: rgba(212, 175, 55, 0.15); color: #b89528; }

.stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-heading);
    line-height: 1.1;
}

.stat-subtext {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ==========================================================================
   Badges & Status Tags
   ========================================================================== */

.badge-status {
    padding: 0.35em 0.75em;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 20px;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-status-received { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.badge-status-review { background: rgba(139, 92, 246, 0.12); color: #7c3aed; }
.badge-status-processing { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.badge-status-pending { background: rgba(236, 72, 153, 0.12); color: #db2777; }
.badge-status-completed { background: rgba(16, 185, 129, 0.12); color: #059669; }
.badge-status-archived { background: rgba(100, 116, 139, 0.12); color: #475569; }
.badge-status-returned { background: rgba(239, 68, 68, 0.12); color: #dc2626; }

.badge-priority-urgent { background: #fee2e2; color: #991b1b; font-weight: 700; border: 1px solid #fca5a5; }
.badge-priority-high { background: #ffedd5; color: #9a3412; font-weight: 600; }
.badge-priority-normal { background: #e0f2fe; color: #075985; }
.badge-priority-low { background: #f1f5f9; color: #475569; }

/* ==========================================================================
   Data Tables & Filter Panels
   ========================================================================== */

.custom-table-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

[data-bs-theme="dark"] .custom-table-card {
    background: #1e293b;
}

.custom-table {
    margin: 0;
}

.custom-table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

[data-bs-theme="dark"] .custom-table th {
    background: #0f172a;
}

.custom-table td {
    padding: 0.95rem 1rem;
    font-size: 0.9rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.custom-table tbody tr {
    transition: background 0.15s ease;
}

.custom-table tbody tr:hover {
    background: rgba(11, 37, 69, 0.02);
}

[data-bs-theme="dark"] .custom-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.tracking-no-link {
    font-family: monospace;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.tracking-no-link:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}

[data-bs-theme="dark"] .tracking-no-link {
    color: #60a5fa;
}

/* Filter Card */
.filter-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.25rem;
    box-shadow: var(--card-shadow);
}

[data-bs-theme="dark"] .filter-card {
    background: #1e293b;
}

/* ==========================================================================
   Visual Status Timeline / Stepper (Communication Details)
   ========================================================================== */

.stepper-wrapper {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.stepper-wrapper::before {
    content: '';
    position: absolute;
    top: 24px;
    left: 40px;
    right: 40px;
    height: 4px;
    background: #e2e8f0;
    z-index: 1;
}

.stepper-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    z-index: 2;
}

.stepper-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #cbd5e1;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.stepper-item.completed .stepper-icon {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
}

.stepper-item.active .stepper-icon {
    background: var(--primary-color);
    border-color: var(--accent-gold);
    color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.3);
}

.stepper-title {
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 0.65rem;
    color: var(--text-heading);
    text-align: center;
}

.stepper-item.active .stepper-title {
    color: var(--primary-color);
}

/* Vertical Processing History Timeline */
.timeline-vertical {
    position: relative;
    padding-left: 2rem;
}

.timeline-vertical::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-event {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: -2rem;
    top: 0.25rem;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 3px solid #ffffff;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.timeline-event-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: var(--card-shadow);
}

[data-bs-theme="dark"] .timeline-event-card {
    background: #1e293b;
}

/* Official GOVPH Topbar */
.govph-topbar {
    background: #002310;
    color: #ffffff;
    font-size: 0.78rem;
    border-bottom: 2px solid var(--accent-gold);
    width: 100%;
    z-index: 1050;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.govph-brand {
    font-weight: 800;
    letter-spacing: 1px;
    color: #ffffff;
}

.govph-divider {
    color: var(--accent-gold);
    opacity: 0.8;
}

.govph-title {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

/* ==========================================================================
   Login Page Styling
   ========================================================================== */

.login-body {
    background: linear-gradient(135deg, #003619 0%, #004d25 40%, #0b2545 85%, #07172b 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.login-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
}

.login-card {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(212, 175, 55, 0.35);
    overflow: hidden;
    max-width: 500px;
    width: 100%;
}

.login-header {
    background: linear-gradient(180deg, #004d25 0%, #003318 100%);
    color: #ffffff;
    padding: 2.25rem 2rem 1.75rem 2rem;
    text-align: center;
    position: relative;
    border-bottom: 3px solid var(--accent-gold);
}

.login-seal-wrapper {
    width: 92px;
    height: 92px;
    background: #ffffff;
    border-radius: 50%;
    padding: 4px;
    margin: 0 auto 1.2rem auto;
    border: 3px solid var(--accent-gold);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 15px rgba(212, 175, 55, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-seal-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.login-lgu-subtitle {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 1.5px;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.login-title {
    font-size: 1.4rem;
    font-weight: 900;
    margin-bottom: 0.2rem;
    letter-spacing: 1px;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.login-subtitle {
    font-size: 0.82rem;
    color: var(--accent-gold);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.login-body-content {
    padding: 2rem;
}

.motto-tagline {
    font-size: 0.78rem;
    font-weight: 700;
    color: #004d25;
    letter-spacing: 0.5px;
}

.demo-account-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-top: 1.25rem;
    font-size: 0.82rem;
}

[data-bs-theme="dark"] .demo-account-box {
    background: #0f172a;
    border-color: #334155;
}

/* ==========================================================================
   Buttons & General Utilities
   ========================================================================== */

.btn-primary-hrmo {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    font-weight: 600;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-primary-hrmo:hover {
    background-color: var(--primary-hover);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(11, 37, 69, 0.25);
}

.btn-gold {
    background-color: var(--accent-gold);
    color: #0b2545;
    border: none;
    font-weight: 700;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-gold:hover {
    background-color: var(--accent-gold-hover);
    color: #0b2545;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
}

/* Print Friendly Utilities */
@media print {
    #sidebar, .topbar, .btn, .filter-card, .no-print {
        display: none !important;
    }
    #content {
        margin: 0 !important;
        padding: 0 !important;
    }
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .custom-table-card {
        border: none !important;
        box-shadow: none !important;
    }
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        position: fixed;
        top: 0;
        bottom: 0;
    }
    #sidebar.show-mobile {
        margin-left: 0;
    }
    .topbar-search {
        display: none;
    }
}
