/* assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette */
    --primary: #6C9A4E;
    --primary-hover: #588040;
    --secondary: #3D5A2B;
    --accent: #A3C957;
    
    /* Utilities */
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --info: #3b82f6;
    
    /* Light Theme (Default) */
    --bg-main: #f3f4f6;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-input: rgba(255, 255, 255, 0.5);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: rgba(255, 255, 255, 0.4);
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --glass-border: rgba(255, 255, 255, 0.18);
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-main: #111827;
    --bg-card: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(0, 0, 0, 0.2);
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --glass-border: rgba(255, 255, 255, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Glassmorphism Component */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    outline: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 154, 78, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 154, 78, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card);
}

/* Inputs & Forms */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 154, 78, 0.2);
}

/* Login Page Specific */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-main) 0%, rgba(108,154,78,0.1) 100%);
    position: relative;
}

.login-bg-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
}

.shape {
    position: absolute;
    filter: blur(80px);
    opacity: 0.5;
    border-radius: 50%;
}

.shape-1 {
    top: -10%;
    left: -10%;
    width: 40vw;
    height: 40vw;
    background: var(--primary);
}

.shape-2 {
    bottom: -10%;
    right: -10%;
    width: 30vw;
    height: 30vw;
    background: var(--accent);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    z-index: 1;
    text-align: center;
}

.login-logo-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

.main-login-logo {
    height: 120px;
    width: auto;
    object-fit: contain;
    background: white; /* Ensure visibility regardless of theme */
    padding: 10px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.login-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    z-index: 100;
    position: relative;
}

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

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.sidebar.collapsed .sidebar-text-logo {
    opacity: 0;
    visibility: hidden;
}

.sidebar-img-logo {
    height: 40px;
    width: auto;
    max-width: 40px;
    object-fit: contain;
    background: white;
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.sidebar.collapsed .sidebar-img-logo {
    height: 36px;
    max-width: 36px;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.menu-item:hover, .menu-item.active {
    color: var(--primary);
    background: rgba(108, 154, 78, 0.1);
    border-left-color: var(--primary);
}

.menu-item i {
    font-size: 18px;
    min-width: 20px;
    text-align: center;
}

.sidebar.collapsed .menu-item span {
    opacity: 0;
    display: none;
}

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

/* Topbar */
.topbar {
    height: 70px;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 90;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.toggle-sidebar-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
}

.toggle-sidebar-btn:hover {
    color: var(--primary);
}

.search-bar {
    position: relative;
    width: 300px;
}

.search-bar i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border-radius: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    outline: none;
    transition: all 0.3s;
}

.search-bar input:focus {
    border-color: var(--primary);
    width: 350px;
    max-width: 100%;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.icon-btn:hover {
    background: var(--bg-card);
    color: var(--primary);
}

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-card);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 4px 12px 4px 4px;
    border-radius: 24px;
    transition: background 0.2s;
}

.user-profile:hover {
    background: var(--bg-input);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* Views Container */
.views-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view-section.active {
    display: block;
}

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

/* Page Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
}

.breadcrumb {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.breadcrumb span {
    color: var(--text-main);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

/* Stats Card */
.stat-card {
    padding: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: transform 0.3s;
}

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

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-title {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
}

.stat-change {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(108, 154, 78, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.chart-card {
    padding: 20px;
    min-height: 350px;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

.chart-container {
    flex: 1;
    position: relative;
    width: 100%;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th, .table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 14px;
}

.table tbody tr {
    transition: background 0.2s;
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.status-completed { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.status-pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.status-failed { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Forms Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* Responsive */
@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Fix: CSS variable negation must use calc() */
    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        transition: left 0.3s ease;
        z-index: 1000;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
        height: 100%;
        top: 0;
    }
    
    .sidebar.mobile-open {
        left: 0;
    }

    /* Hide search bar on mobile to save topbar space */
    .search-bar {
        display: none;
    }

    .charts-grid, .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    /* Layout Adjustments */
    .views-container {
        padding: 16px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .page-header > div {
        width: 100%;
    }
    
    .page-header .btn {
        width: 100%;
        margin-left: 0 !important;
        justify-content: center;
    }
    
    /* Topbar */
    .topbar {
        padding: 0 16px;
    }
    
    .user-name, .user-role {
        display: none;
    }
    
    .user-profile {
        padding: 0;
    }

    /* Topbar right spacing */
    .topbar-right {
        gap: 8px;
    }
    
    /* Login Page */
    .login-page {
        align-items: flex-start;
        padding: 24px 0;
        min-height: 100vh;
        height: auto;
    }

    .login-container {
        padding: 28px 20px;
        margin: 0 16px;
        width: calc(100% - 32px);
        max-width: none;
    }

    /* Notification items: wrap timestamp on small screens */
    .notification-item {
        flex-wrap: wrap;
    }

    .notification-item .notification-time {
        width: 100%;
        margin-left: 56px; /* align under text, past icon */
        margin-top: 4px;
    }
}

@media (max-width: 480px) {
    /* Stack Stat Cards nicely */
    .stat-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 16px;
    }
    
    .stat-icon {
        order: -1;
    }
    
    .stat-info {
        align-items: center;
    }

    /* Stat value slightly smaller on very small screens */
    .stat-value {
        font-size: 22px;
    }
    
    /* Forms and Buttons */
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .card-actions {
        flex-direction: column;
    }
    
    .card-actions .btn {
        width: 100%;
    }
    
    /* Tables: horizontal scroll with visual hint */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    .table {
        min-width: 480px; /* Prevent columns from becoming too narrow */
    }

    .table th, .table td {
        padding: 12px 8px;
        font-size: 13px;
    }

    /* Page title smaller */
    .page-title {
        font-size: 20px;
    }

    /* Topbar icon buttons */
    .icon-btn {
        width: 36px;
        height: 36px;
    }

    /* Login adjustments for very small phones */
    .login-container {
        padding: 24px 16px;
        margin: 0 12px;
    }

    .main-login-logo {
        height: 90px;
    }
}
