/* ==========================================================================
   generalstyle.css - CRM Admin Panel Design System
   Color Palette: Dark Blue, Red, White
   Font: Pinar (from assets/fonts)
   Version: 1.0 - Fully Responsive & Commented
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. FONT FACE DECLARATIONS (0-10)
   -------------------------------------------------------------------------- */
   @font-face {
    font-family: 'Pinar';
    src: url('../assets/fonts/Pinar-DS4-FD-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap; /* Improves perceived load speed */
}

@font-face {
    font-family: 'Pinar';
    src: url('../assets/fonts/Pinar-DS4-FD-Medium.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Pinar';
    src: url('../assets/fonts/Pinar-DS4-FD-SemiBold.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Pinar';
    src: url('../assets/fonts/Pinar-DS4-FD-Bold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Pinar';
    src: url('../assets/fonts/Pinar-DS4-FD-ExtraBold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Pinar';
    src: url('../assets/fonts/Pinar-DS4-FD-Black.ttf') format('truetype');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

/* --------------------------------------------------------------------------
   1. CSS CUSTOM PROPERTIES (VARIABLES) - THEME CONFIG (11-30)
   -------------------------------------------------------------------------- */
:root {
    /* === Color Palette (11-20) === */
    --color-dark-blue-primary: #1a1a2e;   /* Main background, header */
    --color-dark-blue-secondary: #16213e; /* Gradient end, cards */
    --color-dark-blue-hover: #0f3460;     /* Button hovers, interactive elements */
    --color-dark-blue-light: #e8f0fe;     /* Info boxes, light backgrounds */

    --color-red-primary: #e74c3c;         /* Danger, alerts, primary actions */
    --color-red-secondary: #c0392b;       /* Darker red for hover/accents */
    --color-red-light: #fce4e4;           /* Light red for alert backgrounds */

    --color-white: #ffffff;               /* Cards, main content backgrounds */
    --color-off-white: #f5f7fb;           /* Page background */
    --color-border: #e5e7eb;              /* Light borders */

    /* === Text Colors (21-24) === */
    --color-text-primary: #1a1a2e;        /* Main text color */
    --color-text-secondary: #4a5568;      /* Subtitles, meta text */
    --color-text-muted: #6b7280;          /* Muted text, placeholders */
    --color-text-on-dark: #ffffff;        /* Text on dark blue backgrounds */

    /* === Status & Semantic Colors (25-28) === */
    --color-success: #27ae60;
    --color-warning: #f39c12;
    --color-info: #3498db;

    /* === Spacing & Sizing (29-30) === */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    --border-radius: 12px;
    --box-shadow: 0 2px 10px rgba(26, 26, 46, 0.05); /* Dark blue shadow */
    --box-shadow-hover: 0 5px 20px rgba(26, 26, 46, 0.12);
}

/* --------------------------------------------------------------------------
   2. BASE & RESET STYLES (31-45)
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 100%; /* 16px base, allows for rem scaling */
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Pinar', Tahoma, sans-serif;
    background-color: var(--color-off-white);
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--color-dark-blue-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover {
    color: var(--color-dark-blue-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY (46-55)
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    color: var(--color-text-primary);
    font-weight: 600; /* Pinar Bold */
    line-height: 1.3;
}

p {
    margin-bottom: var(--spacing-md);
    color: var(--color-text-secondary);
}

small {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   4. LAYOUT & CONTAINER (56-60)
   -------------------------------------------------------------------------- */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
    width: 100%;
    flex-grow: 1; /* Sticky footer effect if needed */
}

.main-content {
    padding: var(--spacing-xl) 0;
}

/* --------------------------------------------------------------------------
   5. COMPONENTS: HEADER & NAVIGATION (61-70)
   -------------------------------------------------------------------------- */
.header {
    background: linear-gradient(135deg, var(--color-dark-blue-primary), var(--color-dark-blue-secondary));
    color: var(--color-text-on-dark);
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 700; /* ExtraBold */
    color: var(--color-text-on-dark);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.admin-badge {
    background: var(--color-red-primary);
    color: var(--color-white);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.header a,
.header button {
    color: var(--color-text-on-dark);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    transition: background 0.3s ease;
    border: none;
    cursor: pointer;
    font-family: 'Pinar', Tahoma, sans-serif;
    font-weight: 400;
}

.header a:hover,
.header button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--color-white);
}

/* --------------------------------------------------------------------------
   6. COMPONENTS: CARDS & STATS (71-80)
   -------------------------------------------------------------------------- */
.card {
    background: var(--color-white);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: var(--spacing-lg);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--box-shadow-hover);
}

.card h3 {
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-dark-blue-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.stat-card {
    background: var(--color-white);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--box-shadow);
    cursor: pointer;
    transition: all 0.3s ease;
    border-top: 4px solid var(--color-dark-blue-primary);
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--box-shadow-hover);
}

.stat-card .num {
    font-size: 2rem;
    font-weight: 700; /* ExtraBold */
    margin-bottom: var(--spacing-xs);
    color: var(--color-dark-blue-primary);
}

.stat-card .lbl {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    font-weight: 400;
}

/* Specific stat card variants */
.stat-card.red-top { border-top-color: var(--color-red-primary); }
.stat-card.red-top .num { color: var(--color-red-primary); }
.stat-card.success-top { border-top-color: var(--color-success); }
.stat-card.success-top .num { color: var(--color-success); }
.stat-card.warning-top { border-top-color: var(--color-warning); }
.stat-card.warning-top .num { color: var(--color-warning); }

/* --------------------------------------------------------------------------
   7. COMPONENTS: BUTTONS (81-90)
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    font-family: 'Pinar', Tahoma, sans-serif;
    font-size: 0.875rem;
    font-weight: 500; /* SemiBold */
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    line-height: 1.2;
    background: none;
}

.btn:focus-visible {
    outline: 2px solid var(--color-dark-blue-primary);
    outline-offset: 2px;
}

/* Button Variants */
.btn-primary {
    background: var(--color-dark-blue-primary);
    color: var(--color-white);
    border-color: var(--color-dark-blue-primary);
}
.btn-primary:hover {
    background: var(--color-dark-blue-hover);
    border-color: var(--color-dark-blue-hover);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--color-red-primary);
    color: var(--color-white);
    border-color: var(--color-red-primary);
}
.btn-danger:hover {
    background: var(--color-red-secondary);
    border-color: var(--color-red-secondary);
}

.btn-outline {
    background: transparent;
    color: var(--color-dark-blue-primary);
    border-color: var(--color-dark-blue-primary);
}
.btn-outline:hover {
    background: var(--color-dark-blue-primary);
    color: var(--color-white);
}

.btn-outline-danger {
    background: transparent;
    color: var(--color-red-primary);
    border-color: var(--color-red-primary);
}
.btn-outline-danger:hover {
    background: var(--color-red-primary);
    color: var(--color-white);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

/* --------------------------------------------------------------------------
   8. COMPONENTS: FORMS & INPUTS (91-100)
   -------------------------------------------------------------------------- */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.form-control {
    width: 100%;
    padding: 12px var(--spacing-md);
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    font-family: 'Pinar', Tahoma, sans-serif;
    font-size: 0.95rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: var(--color-white);
    color: var(--color-text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-dark-blue-primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.1);
}

.form-control::placeholder {
    color: var(--color-text-muted);
    font-weight: 300;
}

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

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%234a5568' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 16px 12px;
    padding-left: 40px;
}

/* Checkbox & Radio Styles */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-dark-blue-primary);
    cursor: pointer;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 400;
}

/* --------------------------------------------------------------------------
   9. COMPONENTS: TABLES (101-115)
   -------------------------------------------------------------------------- */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: var(--spacing-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--color-white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

thead {
    background: var(--color-off-white);
}

th {
    padding: 14px var(--spacing-md);
    text-align: right;
    font-weight: 600; /* Bold */
    color: var(--color-text-primary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 2px solid var(--color-border);
}

td {
    padding: 14px var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: var(--color-dark-blue-light);
}

/* --------------------------------------------------------------------------
   10. COMPONENTS: BADGES & STATUS (116-125)
   -------------------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-white);
    background: var(--color-dark-blue-primary);
    white-space: nowrap;
}

.badge-danger { background: var(--color-red-primary); }
.badge-success { background: var(--color-success); }
.badge-warning { background: var(--color-warning); color: #1a1a2e; }
.badge-info { background: var(--color-info); }

/* --------------------------------------------------------------------------
   11. COMPONENTS: ALERTS & INFO BOX (126-135)
   -------------------------------------------------------------------------- */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    border: 1px solid;
}

.alert-success {
    background: #e6ffed;
    color: #0a3622;
    border-color: #b7ebcd;
}

.alert-error {
    background: var(--color-red-light);
    color: #721c24;
    border-color: #f5c6cb;
}

.info-box {
    background: var(--color-dark-blue-light);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    color: var(--color-dark-blue-primary);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   12. MODAL STYLES (136-150)
   -------------------------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--color-white);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--color-border);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: color 0.3s;
    line-height: 1;
}
.modal-close:hover {
    color: var(--color-red-primary);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* --------------------------------------------------------------------------
   13. UTILITY CLASSES (151-160)
   -------------------------------------------------------------------------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: var(--spacing-md); }
.mt-2 { margin-top: var(--spacing-lg); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-md); }
.mb-2 { margin-bottom: var(--spacing-lg); }
.flex-center { display: flex; align-items: center; justify-content: center; }
.hidden { display: none; }
.visible-md { display: none; } /* Hidden by default, shown in md screens */

/* --------------------------------------------------------------------------
   14. RESPONSIVE DESIGN (161-200)
   -------------------------------------------------------------------------- */

/* ===== Small devices (landscape phones, less than 768px) ===== */
@media (max-width: 767.98px) {
    :root {
        --spacing-lg: 20px;
        --spacing-xl: 24px;
    }

    .container {
        padding: 0 var(--spacing-md);
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
        padding: var(--spacing-md);
    }

    .header h1 {
        font-size: 1.1rem;
    }

    .header-right,
    .header div {
        width: 100%;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--spacing-sm);
    }

    .stat-card {
        padding: var(--spacing-md);
    }

    .stat-card .num {
        font-size: 1.6rem;
    }

    .grid-2 {
        grid-template-columns: 1fr !important;
        gap: var(--spacing-md);
    }

    .btn {
        width: 100%;
    }

    /* Responsive Tables */
    .table-wrapper {
        margin: 0 -16px; /* Negative margin to allow edge-to-edge scroll */
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 10px var(--spacing-sm);
    }

    /* Modal adjusts */
    .modal {
        padding: var(--spacing-lg);
        width: 95%;
    }

    /* Form adjustments */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: var(--spacing-md);
    }

    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-form .form-group {
        width: 100%;
        min-width: auto;
    }
    
    .visible-xs { display: block; }
}

/* ===== Medium devices (tablets, 768px to 1023px) ===== */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .visible-md { display: block; }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .grid-2 {
        grid-template-columns: 1fr 1fr;
        gap: var(--spacing-lg);
    }
}

/* ===== Large devices (desktops, 1024px and up) ===== */
@media (min-width: 1024px) {
    .container {
        padding: 0 var(--spacing-xl);
    }

    .grid-2 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--spacing-xl);
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* ===== Extra large devices (large desktops, 1400px and up) ===== */
@media (min-width: 1400px) {
    .container {
        max-width: 1500px;
    }
}