/* ============================================
   HONEYGUIDE SACCOS - MODERN THEME
   Inspired by Pipe.com's clean, modern design
   ============================================ */

/* CSS Variables for Theme */
:root {
    /* Primary Colors - Deep Blue & Accents */
    --primary-bg: #0A0E27;
    --primary-dark: #060917;
    --primary-light: #151B3D;
    --accent-blue: #3B82F6;
    --accent-blue-hover: #2563EB;
    --accent-green: #10B981;
    --accent-orange: #F97316;

    /* Neutral Colors */
    --text-primary: #FFFFFF;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border-color: #1E293B;
    --bg-elevated: #0F172A;
    --bg-hover: #1E293B;

    /* Status Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    /* Spacing */
    --sidebar-width: 280px;
    --topbar-height: 64px;
    --content-padding: 2rem;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Light Theme Override */
[data-theme="light"] {
    --primary-bg: #FFFFFF;
    --primary-dark: #F8FAFC;
    --primary-light: #F1F5F9;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --border-color: #E2E8F0;
    --bg-elevated: #FFFFFF;
    --bg-hover: #F8FAFC;
}

/* ============================================
   GLOBAL RESET & BASE STYLES
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--primary-dark);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   LAYOUT STRUCTURE
   ============================================ */

.modern-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.modern-sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: transform var(--transition-normal);
}

.modern-sidebar::-webkit-scrollbar {
    width: 6px;
}

.modern-sidebar::-webkit-scrollbar-track {
    background: var(--primary-bg);
}

.modern-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.modern-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Sidebar Logo */
.sidebar-logo {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo img {
    height: 32px;
    width: auto;
}

.sidebar-logo-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 0.5rem 1.5rem;
    margin-bottom: 0.25rem;
}

.nav-item {
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-left-color: var(--accent-blue);
}

.nav-link.active {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-left-color: var(--accent-blue);
    font-weight: 500;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.nav-link-badge {
    margin-left: auto;
    background-color: var(--accent-blue);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
}

/* Expandable Nav Items */
.nav-item-expandable {
    position: relative;
}

.nav-link-toggle {
    cursor: pointer;
}

.nav-link-arrow {
    margin-left: auto;
    transition: transform var(--transition-fast);
    font-size: 12px;
}

.nav-item-expandable.expanded .nav-link-arrow {
    transform: rotate(90deg);
}

.nav-submenu {
    display: none;
    padding-left: 2.75rem;
}

.nav-item-expandable.expanded .nav-submenu {
    display: block;
}

.nav-submenu .nav-link {
    padding: 0.5rem 1.5rem;
    font-size: 14px;
}

/* Sidebar Footer - User Profile */
.sidebar-user {
    position: sticky;
    bottom: 0;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--primary-bg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.sidebar-user:hover {
    background-color: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* Main Content Area */
.modern-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    background-color: var(--primary-dark);
}

/* Top Bar */
.modern-topbar {
    height: var(--topbar-height);
    background-color: var(--primary-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 999;
}

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

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 0.5rem;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.topbar-search {
    position: relative;
}

.topbar-search input {
    width: 300px;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    background-color: var(--primary-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.topbar-search input::placeholder {
    color: var(--text-muted);
}

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

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: var(--primary-light);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    position: relative;
}

.topbar-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.topbar-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    min-width: 18px;
}

/* Content Area */
.modern-content {
    padding: var(--content-padding);
}

/* ============================================
   CARDS & COMPONENTS
   ============================================ */

.modern-card {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.modern-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

/* Stat Cards */
.stat-card {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-bg));
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 70px;
    height: 70px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.1), transparent);
    border-radius: 50%;
}

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

.stat-label i {
    font-size: 10.5px;
    margin-right: 2px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
    line-height: 1.15;
}

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

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

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

/* ==================== Compact Stat Card (stat-card-c) ==================== */
.stat-card-c {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.7rem 0.85rem 0.7rem 0.95rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card-c:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
}

.stat-card-c__rail {
    position: absolute;
    left: 0;
    top: 12%;
    bottom: 12%;
    width: 3px;
    background: #6366f1;
    border-radius: 0 3px 3px 0;
}

.stat-card-c__icon {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef2ff;
    color: #4338ca;
    font-size: 14px;
}

.stat-card-c__icon i {
    font-size: 14px;
    line-height: 1;
}

.stat-card-c__body {
    flex: 1 1 auto;
    min-width: 0;
}

.stat-card-c__label {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.2;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card-c__value {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.15;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card-c__sub {
    font-size: 10.5px;
    color: #94a3b8;
    margin-top: 2px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card-c--gradient {
    background: linear-gradient(135deg, #6366f1, #14b8a6);
    border-color: transparent;
    color: #fff;
}

.stat-card-c--gradient .stat-card-c__icon {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.stat-card-c--gradient .stat-card-c__label,
.stat-card-c--gradient .stat-card-c__value,
.stat-card-c--gradient .stat-card-c__sub {
    color: #ffffff !important;
}

.stat-card-c--gradient .stat-card-c__sub {
    opacity: 0.9;
}

.stat-card-c--gradient .stat-card-c__rail {
    background: rgba(255, 255, 255, 0.6);
}

@media (max-width: 480px) {
    .stat-card-c {
        padding: 0.6rem 0.75rem 0.6rem 0.85rem;
        gap: 8px;
    }
    .stat-card-c__icon { width: 32px; height: 32px; font-size: 13px; }
    .stat-card-c__value { font-size: 16px; }
    .stat-card-c__label { font-size: 9.5px; }
}

/* Buttons */
.btn-modern {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background-color: var(--accent-blue-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--primary-light);
    color: var(--text-primary);
}

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

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

.btn-success:hover {
    background-color: #059669;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-warning {
    background-color: #F59E0B;
    color: #1F2937;
    font-weight: 600;
}

.btn-warning:hover {
    background-color: #D97706;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-info {
    background-color: #06B6D4;
    color: white;
    font-weight: 600;
}

.btn-info:hover {
    background-color: #0891B2;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-danger:hover {
    background-color: #DC2626;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.modern-table thead {
    background-color: var(--primary-light);
}

.modern-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modern-table td {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.modern-table tbody tr:hover {
    background-color: var(--bg-hover);
}

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

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

.form-control,
.form-control-modern {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--primary-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.form-control:focus,
.form-control-modern:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control::placeholder,
.form-control-modern::placeholder {
    color: var(--text-muted);
}

.form-control:read-only,
.form-control-modern:read-only {
    background-color: var(--bg-elevated);
    cursor: not-allowed;
    opacity: 0.7;
}

.form-control:disabled,
.form-control-modern:disabled {
    background-color: var(--bg-elevated);
    cursor: not-allowed;
    opacity: 0.5;
}

select.form-control,
select.form-control-modern {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

textarea.form-control,
textarea.form-control-modern {
    resize: vertical;
    min-height: 100px;
}

.form-check-input {
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* Alerts */
.alert-modern {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning);
    color: var(--warning);
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */

@media (max-width: 1024px) {
    :root {
        --content-padding: 1.5rem;
    }

    .topbar-search input {
        width: 200px;
    }
}

@media (max-width: 768px) {
    :root {
        --content-padding: 1rem;
    }

    /* Hide sidebar by default on mobile */
    .modern-sidebar {
        transform: translateX(-100%);
    }

    .modern-sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Adjust main content */
    .modern-main {
        margin-left: 0;
    }

    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: block;
    }

    /* Hide search on mobile */
    .topbar-search {
        display: none;
    }

    .modern-topbar {
        padding: 0 1rem;
    }

    .page-title {
        font-size: 18px;
    }

    /* Stat cards smaller text */
    .stat-value {
        font-size: 18px;
    }

    /* Stack form elements */
    .form-row {
        flex-direction: column;
    }

    /* Responsive tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modern-table {
        font-size: 12px;
        min-width: auto !important;
    }

    .modern-table th,
    .modern-table td {
        padding: 0.5rem 0.4rem;
        font-size: 12px;
    }

    .modern-table th {
        font-size: 10px;
    }

    /* Force mobile card view for tables on small screens */
    .table-responsive {
        display: none !important;
    }

    .table-responsive + div {
        display: block !important;
    }

    /* Reduce stat card grid columns on mobile */
    [style*="grid-template-columns"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Stack page header actions */
    .page-header-actions {
        flex-direction: column;
        width: 100%;
    }

    /* Stack filters in mobile */
    [style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    .modern-content {
        padding: 0.75rem;
    }

    .modern-card {
        padding: 1rem;
    }

    .stat-card {
        padding: 0.7rem 0.85rem;
    }
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .mobile-overlay.active {
        display: block;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.slide-in {
    animation: slideIn 0.3s ease;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }

.d-flex { display: flex !important; }
.flex-column { flex-direction: column !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.gap-1 { gap: 0.5rem !important; }
.gap-2 { gap: 1rem !important; }
.gap-3 { gap: 1.5rem !important; }

/* ============================================
   INPUT READABILITY SAFETY NET
   Defends against pages that hard-code
   `background: white` on inputs while a dark
   theme has set the inherited text color to
   white (Bootstrap default form-control). Any
   white-bg input gets a guaranteed dark text.
   ============================================ */
input[type="text"]:not([style*="color"]),
input[type="email"]:not([style*="color"]),
input[type="tel"]:not([style*="color"]),
input[type="number"]:not([style*="color"]),
input[type="password"]:not([style*="color"]),
input[type="search"]:not([style*="color"]),
input[type="url"]:not([style*="color"]),
input[type="date"]:not([style*="color"]),
textarea:not([style*="color"]),
select:not([style*="color"]) {
    color-scheme: light dark;
}
