/* ============================================================
   A1 Freedom Pest Control — Admin Panel CSS
   ============================================================ */

:root {
    --primary:        #e51d22;
    --primary-dark:   #c0181c;
    --primary-light:  rgba(229, 29, 34, 0.15);
    --dark:           #1a1a18;
    --dark-2:         #252522;
    --dark-3:         #2e2e2b;
    --sidebar-width:  260px;
    --topbar-height:  62px;
    --text-muted:     #9a9a96;
    --border-color:   #e4e4e2;
    --card-shadow:    0 2px 12px rgba(0,0,0,.07);
    --radius:         12px;
    --radius-sm:      8px;
    --font-sans:      'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: .9375rem;
    background: #f4f4f2;
    color: #2d2d2b;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--dark);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .3s ease, width .3s ease;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 22px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    min-height: var(--topbar-height);
    text-decoration: none;
}
.sidebar-brand-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    color: #fff;
}
.sidebar-brand-text {
    line-height: 1.2;
}
.sidebar-brand-text strong {
    display: block;
    color: #fff;
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: .01em;
}
.sidebar-brand-text small {
    color: var(--text-muted);
    font-size: .72rem;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 14px 0;
    list-style: none;
    margin: 0;
}
.sidebar-nav .nav-section-label {
    padding: 16px 22px 6px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #555550;
}
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 22px;
    color: #b0b0aa;
    font-size: .875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background .18s, color .18s, border-color .18s;
    white-space: nowrap;
    text-decoration: none;
}
.sidebar-nav li a i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-nav li a .nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    border-radius: 20px;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
}
.sidebar-nav li a:hover {
    background: rgba(255,255,255,.05);
    color: #fff;
    border-left-color: rgba(229,29,34,.5);
}
.sidebar-nav li.active > a {
    background: var(--primary-light);
    color: #fff;
    border-left-color: var(--primary);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 14px 22px;
    border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #777770;
    font-size: .82rem;
    text-decoration: none;
    padding: 6px 0;
    transition: color .18s;
}
.sidebar-footer a:hover { color: var(--primary); }

/* ── Top Bar ──────────────────────────────────────────────── */
#topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 1030;
    gap: 16px;
}
.topbar-toggle {
    display: none;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: #555;
    font-size: 1.25rem;
    border-radius: 6px;
    transition: background .15s;
}
.topbar-toggle:hover { background: #f0f0ee; }

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a18;
    margin: 0;
}
.topbar-spacer { flex: 1; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar-avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: .88rem;
    flex-shrink: 0;
}
.topbar-user-info strong {
    display: block;
    font-size: .84rem;
    font-weight: 600;
    color: #1a1a18;
    line-height: 1.2;
}
.topbar-user-info small {
    color: var(--text-muted);
    font-size: .72rem;
}
.topbar-logout {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: .82rem;
    color: #666;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: background .15s, color .15s, border-color .15s;
    text-decoration: none;
}
.topbar-logout:hover {
    background: #fff1f1;
    color: var(--primary);
    border-color: var(--primary);
}

/* ── Main Content ─────────────────────────────────────────── */
#main-content {
    margin-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    min-height: 100vh;
}
.content-area {
    padding: 28px 28px 40px;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}
.page-header .breadcrumb {
    margin: 0;
    background: none;
    padding: 0;
    font-size: .8rem;
}
.page-header .breadcrumb-item.active { color: var(--text-muted); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-header h5, .card-header h6 {
    margin: 0;
    font-weight: 600;
    font-size: .95rem;
}
.card-body { padding: 20px; }
.card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    background: transparent;
    border-radius: 0 0 var(--radius) var(--radius) !important;
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 22px 22px 18px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,.1);
}
.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-icon.red    { background: rgba(229,29,34,.12); color: var(--primary); }
.stat-icon.blue   { background: rgba(13,110,253,.12); color: #0d6efd; }
.stat-icon.green  { background: rgba(25,135,84,.12);  color: #198754; }
.stat-icon.orange { background: rgba(253,126,20,.12); color: #fd7e14; }
.stat-icon.purple { background: rgba(111,66,193,.12); color: #6f42c1; }

.stat-info { flex: 1; min-width: 0; }
.stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--dark);
    line-height: 1;
    margin-bottom: 4px;
}
.stat-label {
    font-size: .82rem;
    color: var(--text-muted);
    font-weight: 500;
}
.stat-change {
    font-size: .78rem;
    margin-top: 6px;
}
.stat-change.up   { color: #198754; }
.stat-change.down { color: var(--primary); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table thead th {
    background: #f8f8f6;
    color: #555;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 12px 14px;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
}
.admin-table tbody tr {
    transition: background .15s;
}
.admin-table tbody tr:hover {
    background: #f9f9f7;
}
.admin-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f0ee;
    vertical-align: middle;
    font-size: .875rem;
}
.admin-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.badge-new        { background: rgba(13,110,253,.12);  color: #0d6efd;  }
.badge-contacted  { background: rgba(253,126,20,.12);  color: #fd7e14;  }
.badge-completed  { background: rgba(25,135,84,.12);   color: #198754;  }
.badge-spam       { background: rgba(108,117,125,.12); color: #6c757d;  }
.badge-active     { background: rgba(25,135,84,.12);   color: #198754;  }
.badge-inactive   { background: rgba(108,117,125,.12); color: #6c757d;  }
.badge-published  { background: rgba(25,135,84,.12);   color: #198754;  }
.badge-draft      { background: rgba(108,117,125,.12); color: #6c757d;  }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: capitalize;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-label {
    font-size: .84rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 5px;
}
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid #ddd;
    font-size: .875rem;
    padding: 8px 12px;
    transition: border-color .18s, box-shadow .18s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(229,29,34,.12);
    outline: none;
}
.form-hint {
    font-size: .76rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.char-counter {
    font-size: .74rem;
    color: var(--text-muted);
    float: right;
}
.char-counter.warn { color: #fd7e14; }
.char-counter.over { color: var(--primary); }

/* Input group */
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Image Preview ────────────────────────────────────────── */
.img-preview-wrap {
    position: relative;
    display: inline-block;
    margin-top: 8px;
}
.img-preview {
    width: 120px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
}
.img-preview-remove {
    position: absolute;
    top: -6px; right: -6px;
    width: 20px; height: 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: .7rem;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}

/* ── Drag Handle ──────────────────────────────────────────── */
.drag-handle {
    cursor: grab;
    color: #ccc;
    font-size: 1rem;
    padding: 0 6px;
}
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: .4; }

/* ── Toggle Switch ────────────────────────────────────────── */
.form-switch .form-check-input {
    width: 2.2em;
    height: 1.15em;
}
.form-switch .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}
.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(229,29,34,.2);
    border-color: var(--primary);
}

/* ── Tabs ─────────────────────────────────────────────────── */
.nav-tabs { border-bottom: 2px solid var(--border-color); }
.nav-tabs .nav-link {
    color: #666;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 10px 18px;
    font-weight: 500;
    font-size: .875rem;
    border-radius: 0;
    transition: color .15s, border-color .15s;
}
.nav-tabs .nav-link:hover { color: var(--primary); border-color: transparent; }
.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: none;
}
.tab-content { padding-top: 20px; }

/* ── DataTables overrides ─────────────────────────────────── */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1.5px solid #ddd;
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: .84rem;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(229,29,34,.1);
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    font-size: .82rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #f0f0ee !important;
    border-color: #ddd !important;
    color: #333 !important;
}

/* ── Login Page ───────────────────────────────────────────── */
.login-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--dark) 0%, #2a2a27 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo .brand-icon {
    width: 56px; height: 56px;
    background: var(--primary);
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    margin-bottom: 12px;
}
.login-logo h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0 0 4px;
}
.login-logo p {
    font-size: .82rem;
    color: var(--text-muted);
    margin: 0;
}
.login-card .form-control {
    height: 46px;
    padding-left: 42px;
}
.login-input-wrap {
    position: relative;
}
.login-input-wrap i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    font-size: 1rem;
    pointer-events: none;
}
.btn-login {
    width: 100%;
    height: 46px;
    background: var(--primary);
    border: none;
    color: #fff;
    font-weight: 700;
    font-size: .95rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .18s, transform .15s;
}
.btn-login:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-header { border-bottom: 1px solid var(--border-color); }
.modal-footer { border-top: 1px solid var(--border-color); }
.modal-content { border-radius: var(--radius); border: none; box-shadow: 0 20px 60px rgba(0,0,0,.2); }

/* ── Chart ────────────────────────────────────────────────── */
.chart-container { position: relative; }

/* ── Thumbnail ────────────────────────────────────────────── */
.thumb-sm {
    width: 50px; height: 36px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}
.thumb-icon {
    width: 50px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #f0f0ee;
    border-radius: 6px;
    font-size: 1.3rem;
}

/* ── Alert strip ──────────────────────────────────────────── */
.alert-strip {
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: .875rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Enquiry Detail ───────────────────────────────────────── */
.detail-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 20px;
}
.detail-section-header {
    background: #f8f8f6;
    padding: 10px 16px;
    font-size: .78rem;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border-color);
}
.detail-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0;
    border-bottom: 1px solid #f0f0ee;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
    padding: 10px 16px;
    font-size: .8rem;
    font-weight: 600;
    color: #777;
    background: #fafaf8;
    border-right: 1px solid #f0f0ee;
}
.detail-value {
    padding: 10px 16px;
    font-size: .875rem;
    color: #333;
    word-break: break-word;
}

/* ── Quick actions ────────────────────────────────────────── */
.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 12px;
    background: #fff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    text-decoration: none;
    color: #555;
    font-size: .8rem;
    font-weight: 600;
    transition: background .15s, border-color .15s, color .15s, transform .2s;
    box-shadow: var(--card-shadow);
}
.quick-action-btn i {
    font-size: 1.6rem;
    color: var(--primary);
}
.quick-action-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
    #sidebar {
        transform: translateX(-100%);
        z-index: 1050;
        box-shadow: 4px 0 30px rgba(0,0,0,.3);
    }
    #sidebar.show {
        transform: translateX(0);
    }
    #topbar {
        left: 0;
    }
    #main-content {
        margin-left: 0;
    }
    .topbar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 1045;
    }
    .sidebar-overlay.show { display: block; }
    .content-area { padding: 20px 16px 30px; }
}

@media (max-width: 575.98px) {
    .stat-value { font-size: 1.5rem; }
    .topbar-user-info { display: none; }
    .login-card { padding: 28px 20px; }
    .detail-row { grid-template-columns: 1fr; }
    .detail-label { border-right: none; border-bottom: 1px solid #f0f0ee; }
}

/* ── Utilities ────────────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.bg-primary   { background: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }
.rotate-icon  { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Color picker preview */
.color-swatch {
    width: 32px; height: 32px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
}
.color-swatch input[type=color] {
    width: 200%;
    height: 200%;
    margin: -25%;
    border: none;
    cursor: pointer;
    opacity: 0;
    position: absolute;
    inset: 0;
}
.color-swatch-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}
