/* =========================================
   MODERN DESIGN SYSTEM
   ========================================= */
:root {
    /* Color Palette */
    --primary: #198754;
    --primary-dark: #146c43;
    --primary-light: #d1e7dd;
    --secondary: #6c757d;
    --success: #2ecc71;
    --info: #3498db;
    --warning: #f1c40f;
    --danger: #e74c3c;
    --dark: #212529;
    --light: #f8f9fa;

    /* Backgrounds */
    --bg-body: #f4f6f8;
    --bg-surface: #ffffff;
    --bg-sidebar: #1e293b;
    /* Modern Dark Blue-Grey */

    /* Typography */
    --font-family-sans: 'Inter', system-ui, -apple-system, sans-serif;

    /* Spacing & Radius */
    --border-radius-sm: 8px;
    --border-radius: 12px;
    --border-radius-lg: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-nav: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

/* =========================================
   GLOBAL RESET & TYPOGRAPHY
   ========================================= */
body {
    background-color: var(--bg-body);
    font-family: var(--font-family-sans);
    color: #334155;
    /* Slate 700 */
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    color: #1e293b;
    /* Slate 800 */
    letter-spacing: -0.025em;
}

a {
    text-decoration: none;
    transition: color 0.2s ease;
}

/* =========================================
   COMPONENTS
   ========================================= */

/* Cards */
.card,
.app-card {
    background: var(--bg-surface);
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 1.5rem;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #e2e8f0;
    padding: 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

/* Dashboard Cards (Gradient) */
.dashboard-card {
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.card-green {
    background: linear-gradient(135deg, #10b981, #059669);
}

.card-blue {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.card-orange {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.card-red {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* Buttons */
.btn {
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Form Inputs */
.form-control,
.form-select {
    border-radius: var(--border-radius-sm);
    border: 1px solid #cbd5e1;
    padding: 0.625rem 1rem;
    box-shadow: var(--shadow-sm);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.15);
}

/* Tables (DataTables) */
.table {
    margin-bottom: 0;
    vertical-align: middle;
}

.table thead th {
    background-color: #f8fafc;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--border-radius-sm);
    border: 1px solid #cbd5e1;
    padding: 0.4rem;
}

/* =========================================
   LAYOUT: SIDEBAR & HEADER
   ========================================= */

/* Header */
header.bg-success {
    background: linear-gradient(to right, #198754, #146c43) !important;
    padding: 1rem !important;
}

/* Navbar */
.navbar-dark.bg-dark {
    background-color: var(--bg-sidebar) !important;
}

/* Sidebar (Desktop) */
.col-lg-2.d-none.d-lg-block {
    background-color: var(--bg-sidebar) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
}

.nav-link {
    color: #94a3b8;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.25rem;
    transition: all 0.2s;
}

.nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: #fff;
    background-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.nav-link i {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

/* =========================================
   MOBILE APP STYLES (Max-width: 992px)
   ========================================= */
@media (max-width: 992px) {
    body {
        margin-bottom: 80px;
        /* More space for modern nav */
    }

    /* App Header */
    .app-header {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        color: var(--dark);
        padding: 1rem 1.25rem;
        position: sticky;
        top: 0;
        z-index: 1000;
        box-shadow: var(--shadow-sm);
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    .app-header h4 {
        font-size: 1.1rem;
        margin: 0;
        color: var(--primary-dark);
    }

    .app-header i {
        color: var(--secondary);
        font-size: 1.2rem;
    }

    /* App Grid */
    .app-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
        padding: 0.5rem 0;
    }

    .app-icon-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: var(--dark);
        transition: transform 0.1s;
    }

    .app-icon-item:active {
        transform: scale(0.96);
    }

    .app-icon-box {
        width: 60px;
        height: 60px;
        border-radius: 20px;
        /* Squircle */
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        color: white;
        margin-bottom: 0.5rem;
        box-shadow: var(--shadow-md);
    }

    .app-icon-item span {
        font-size: 0.75rem;
        font-weight: 500;
        color: #64748b;
    }

    /* Colors for Icons */
    .bg-green {
        background: linear-gradient(135deg, #34d399, #059669);
    }

    .bg-blue {
        background: linear-gradient(135deg, #60a5fa, #2563eb);
    }

    .bg-red {
        background: linear-gradient(135deg, #f87171, #dc2626);
    }

    .bg-orange {
        background: linear-gradient(135deg, #fbbf24, #d97706);
    }

    .bg-teal {
        background: linear-gradient(135deg, #2dd4bf, #0d9488);
    }

    .bg-purple {
        background: linear-gradient(135deg, #a78bfa, #7c3aed);
    }

    .bg-dark {
        background: linear-gradient(135deg, #475569, #1e293b);
    }

    /* Bottom Navigation (Glassmorphism) */
    .app-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        display: flex;
        justify-content: space-around;
        align-items: center;
        box-shadow: var(--shadow-nav);
        z-index: 1050;
        border-top: 1px solid rgba(255, 255, 255, 0.5);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #94a3b8;
        font-size: 0.7rem;
        width: 20%;
        height: 100%;
        transition: color 0.2s;
    }

    .nav-btn i {
        font-size: 1.4rem;
        margin-bottom: 4px;
        transition: transform 0.2s;
    }

    .nav-btn.active {
        color: var(--primary);
    }

    .nav-btn.active i {
        transform: translateY(-2px);
    }

    /* =========================================
       MOBILE BUTTON STYLES
       ========================================= */

    /* Base Button Styles for Mobile */
    .btn {
        min-height: 44px;
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }

    /* Button Sizing */
    .btn-sm {
        min-height: 38px;
        padding: 0.5rem 0.875rem;
        font-size: 0.85rem;
    }

    .btn-lg {
        min-height: 50px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Button Spacing */
    .btn+.btn {
        margin-left: 0.5rem;
    }

    /* Button Groups in Tables */
    .btn-group {
        display: flex;
        gap: 0.25rem;
        flex-wrap: nowrap;
    }

    .btn-group .btn {
        min-width: 44px;
        padding: 0.5rem;
        flex-shrink: 0;
    }

    .btn-group-sm .btn {
        min-width: 38px;
        min-height: 38px;
        padding: 0.4rem;
        font-size: 0.875rem;
    }

    /* Action Buttons in Tables */
    table .btn-group {
        justify-content: center;
    }

    table .btn {
        min-width: 40px;
        padding: 0.5rem 0.625rem;
    }

    /* Header Action Buttons */
    .d-flex.justify-content-between .btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
        white-space: nowrap;
    }

    /* Icon Buttons */
    .btn i {
        font-size: 1rem;
        margin-right: 0.25rem;
    }

    .btn-sm i {
        font-size: 0.875rem;
    }

    .btn-lg i {
        font-size: 1.1rem;
        margin-right: 0.5rem;
    }

    .btn i:only-child {
        margin-right: 0;
    }

    /* Responsive Button Layout for very small screens */
    @media (max-width: 576px) {
        .d-flex.justify-content-between {
            flex-direction: column;
            align-items: stretch !important;
        }

        .d-flex.justify-content-between .btn {
            width: 100%;
            margin-bottom: 0.5rem;
        }


        ::-webkit-scrollbar-track {
            background: #f1f5f9;
        }

        ::-webkit-scrollbar-thumb {
            background: #cbd5e1;
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
        }

        /* DataTables Polish */
        .dataTables_wrapper .dataTables_paginate .paginate_button.current,
        .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
            background: var(--primary) !important;
            color: white !important;
            border: 1px solid var(--primary) !important;
            border-radius: 6px !important;
        }

        .dataTables_wrapper .dataTables_paginate .paginate_button {
            border-radius: 6px !important;
            border: 1px solid transparent !important;
        }

        .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
            background: #e2e8f0 !important;
            color: var(--dark) !important;
            border: 1px solid #cbd5e1 !important;
        }

        .dataTables_wrapper .dataTables_filter input {
            border: 1px solid #cbd5e1;
            border-radius: 6px;
            padding: 6px 12px;
            outline: none;
            transition: border-color 0.2s;
        }

        .dataTables_wrapper .dataTables_filter input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.1);
        }

        /* Animations */
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .container,
        .container-fluid {
            animation: fadeIn 0.4s ease-out;
        }

        /* Dropdowns */
        .dropdown-menu {
            border: none;
            box-shadow: var(--shadow-lg);
            border-radius: 12px;
            padding: 8px;
        }

        .dropdown-item {
            border-radius: 6px;
            padding: 8px 16px;
            font-weight: 500;
            color: #475569;
        }

        .dropdown-item:hover {
            background-color: #f1f5f9;
            color: var(--primary);
        }

        .dropdown-item.active,
        .dropdown-item:active {
            background-color: var(--primary);
            color: white;
        }
    }
}

/* =========================================
   ADDITIONAL MOBILE OPTIMIZATIONS
   ========================================= */
@media (max-width: 992px) {
    /* Table responsive */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table td, .table th {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
        white-space: nowrap;
    }
    
    /* Gap and flex utilities */
    .gap-2 { gap: 0.5rem !important; }
    .flex-wrap { flex-wrap: wrap !important; }
    
    /* Hide text on smaller screens */
    .d-none.d-sm-inline { display: none !important; }
    .d-none.d-md-inline { display: none !important; }
    .d-none.d-lg-inline { display: none !important; }
    
    /* Container padding */
    .container, .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Card optimization */
    .card { margin-bottom: 1rem; }
    .card-header { padding: 1rem; font-size: 0.95rem; }
    .card-body { padding: 1rem; }
    
    /* Badge sizing */
    .badge {
        padding: 0.375rem 0.625rem;
        font-size: 0.8rem;
    }
    
    /* Alert optimization */
    .alert {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    /* Form optimization */
    .form-control, .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    label {
        margin-bottom: 0.5rem;
        font-weight: 500;
    }
}
