﻿:root {
    --primary-color: #38bdf8;
    /* Vibrant Sky Blue from Logo */
    --primary-dark: #0ea5e9;
    --secondary-color: #0c4a6e;
    /* Deep Cyan for contrast */
    --accent-color: #22d3ee;
    --danger-color: #f43f5e;
    --warning-color: #f59e0b;

    /* Theme Colors (Clean Sky Blue Theme) */
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --sidebar-bg: #ffffff;
    /* Clean White Sidebar */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #e2e8f0;

    --sidebar-text: #64748b;
    --sidebar-text-hover: #0f172a;
    --sidebar-active-bg: #f0f9ff;
    --sidebar-active-text: #38bdf8;

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --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);

    --font-family: 'Inter',
        system-ui,
        -apple-system,
        sans-serif;
}

/* Delete/Danger Actions Highlighting */
.dropdown-item.text-danger:hover {
    background-color: var(--danger-color) !important;
    color: white !important;
}

.dropdown-item.text-danger:hover i {
    color: white !important;
}

/* Custom Scrollbar Styling (Vibrant Sky Blue Theme) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Collapsed Sidebar */
.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .dropdown-icon,
.sidebar.collapsed .sidebar-footer-text,
.sidebar.collapsed .nav-dropdown-menu {
    display: none !important;
}

.sidebar.collapsed .sidebar-header {
    padding: 1.25rem 0;
    justify-content: center !important;
}

.sidebar.collapsed .nav-links li a {
    padding: 0.75rem 0;
    justify-content: center;
}

.sidebar.collapsed .nav-links li a i {
    font-size: 1.25rem;
    margin: 0;
}

.sidebar.collapsed .sidebar-footer-link {
    justify-content: center;
    padding: 0.75rem 0;
}

.sidebar.collapsed .sidebar-footer {
    padding: 1rem 0;
}

.sidebar-nav-container {
    flex: 1;
    overflow-y: auto;
}

.sidebar-footer {
    padding: 1rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.sidebar-footer-link:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.sidebar-footer-text {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.5rem;
    line-height: 1.4;
    opacity: 0.8;
}

.sidebar-header {
    padding: 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    list-style: none;
    padding: 1rem 0;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--sidebar-text);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-links li a:hover {
    color: var(--sidebar-text-hover);
    background-color: rgba(0, 0, 0, 0.03);
}

.nav-links li a.active {
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--radius-md);
    margin: 0 0.75rem;
}

/* Sidebar Submenu */
.nav-item-has-submenu {
    position: relative;
}

.nav-dropdown-toggle {
    display: flex;
    justify-content: space-between !important;
    cursor: pointer;
}

.dropdown-icon {
    transition: transform 0.3s ease;
}

.nav-item-has-submenu.open .dropdown-icon {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    display: none;
    list-style: none;
    padding-left: 0;
    background-color: rgba(0, 0, 0, 0.02);
    margin: 0 0.75rem;
    border-radius: var(--radius-md);
}

.nav-item-has-submenu.open .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-item {
    padding-left: 3rem !important;
    /* Indent sub-items */
    font-size: 0.9em;
}

.nav-dropdown-item::before {
    content: '';
    /* Optional: add a dot or line indicator */
}

/* User Menu & Dropdown Styles */
.user-menu-container {
    position: relative;
    cursor: pointer;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: background-color 0.2s;
}

.user-profile:hover {
    background-color: var(--background-color);
}

.user-info {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background-color: #6366f1;
    /* Purpleish */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    width: 260px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    z-index: 100;
    display: none;
    transform-origin: top right;
    animation: scaleIn 0.2s ease-out;
}

.profile-dropdown.show {
    display: block;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.dropdown-header {
    margin-bottom: 0.75rem;
}

.dropdown-header strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.theme-toggles {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
}

.theme-btn {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    background-color: var(--background-color);
    color: var(--text-primary);
}

.theme-btn.active {
    background-color: #6366f1;
    /* Active Theme Color */
    color: white;
    border-color: #6366f1;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background-color: var(--background-color);
    color: var(--primary-color);
}

.dropdown-item.text-danger:hover {
    color: var(--danger-color);
    background-color: #fef2f2;
}

.separator {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.top-bar {
    height: 64px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: var(--shadow-sm);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-content {
    padding: 1.5rem;
    max-width: 100%;
    margin: 0;
    width: 100%;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--secondary-color);
    font-weight: 600;
    margin-bottom: 1rem;
}

h1 {
    font-size: 1.875rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

/* Components */
.card {
    background-color: var(--surface-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--background-color);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: #10b981;
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* Tables */
.table-responsive {
    width: 100%;
    /* Remove overflow:auto or hidden to ensure dropdowns can escape */
    overflow: visible;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
    font-weight: 600;
    color: white;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.075em;
    border: none;
    box-shadow: 0 2px 4px rgba(14, 165, 233, 0.15);
}

.dark .table th {
    background: linear-gradient(135deg, #0c4a6e 0%, #0369a1 100%);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(3, 105, 161, 0.2);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.badge {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-blue {
    background-color: #e0f2fe;
    color: #075985;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--primary-color);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin: 0.5rem 0;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-dark) 100%);
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

/* Action Dropdown Styles */
.actions-dropdown {
    position: relative;
    display: inline-block;
}

.actions-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.actions-btn:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 180px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding: 0.5rem 0;
}

.actions-dropdown.active .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f8fafc;
}

.dropdown-item i {
    width: 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.dropdown-item.text-danger {
    color: #ef4444;
}

.dropdown-item.text-danger i {
    color: #ef4444;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

/* Page Transitions */
.page-fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .sidebar { width: 240px; }
    .top-bar { padding: 0 1.5rem; }
}

@media (max-width: 768px) {
    .app-container { position: relative; }
    
    .sidebar {
        display: none !important;
    }
    
    #sidebarToggle {
        display: none !important;
    }

    .main-content { 
        margin-left: 0; 
        width: 100%; 
        overflow-x: hidden;
        height: calc(100vh - 65px);
        padding-bottom: 75px; 
    }

    .top-bar { 
        padding: 0 1rem;
        position: sticky;
        top: 0;
        z-index: 900;
    }
    .user-info { display: none; }
    .page-content { padding: 1rem; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .table-responsive { 
        overflow-x: auto; 
        -webkit-overflow-scrolling: touch; 
        margin-bottom: 1rem; 
    }
    .card { padding: 1rem; }
    .card-header { 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 1rem; 
    }
    .card-header .btn { width: 100%; }
    
    .bottom-nav {
        display: flex !important;
    }
}

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    flex: 1;
    height: 100%;
    transition: all 0.3s ease;
    gap: 4px;
    position: relative;
}

.bottom-nav-item i {
    font-size: 1.25rem;
    transition: transform 0.3s ease;
}

.bottom-nav-item.active {
    color: var(--primary-color);
}

.bottom-nav-item.active i {
    transform: translateY(-2px);
}

.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 0 0 4px 4px;
}

@media (max-width: 480px) {
    .top-bar h3 { font-size: 1.1rem; }
    .user-avatar { width: 32px; height: 32px; font-size: 0.9rem; }
    .btn { width: 100%; }
    .stat-value { font-size: 1.5rem; }
}
