/* ============================================
   Ad Grant Automation — Custom Theme
   ============================================ */

:root {
    --primary: #33AEF4;
    --primary-hover: #1a9be0;
    --primary-light: #e8f6fe;
    --primary-50: rgba(51, 174, 244, 0.08);
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1e293b;
    --muted: #94a3b8;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Base ---- */
body {
    background-color: var(--body-bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--dark);
    -webkit-font-smoothing: antialiased;
}

/* ---- Navbar ---- */
.app-navbar {
    background: linear-gradient(135deg, #1a8fd4 0%, #33AEF4 100%);
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1030;
}
.app-navbar .navbar-brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
}
.app-navbar .navbar-brand img {
    height: 32px;
    width: auto;
    border-radius: 6px;
}
.app-navbar .nav-link {
    color: rgba(255,255,255,0.8);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    transition: all var(--transition);
}
.app-navbar .nav-link:hover,
.app-navbar .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.15);
}

/* ---- Page wrapper ---- */
.page-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}
.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
    letter-spacing: -0.02em;
}
.page-header .subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* ---- Cards ---- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.card:hover {
    box-shadow: var(--shadow);
}
.card .card-body {
    padding: 1.5rem;
}
.card .card-footer {
    background: transparent;
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}
.card-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--dark);
}

/* ---- Stat cards ---- */
.stat-card {
    text-align: center;
    padding: 1.25rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
    font-weight: 500;
}

/* ---- Buttons ---- */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: var(--radius);
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    transition: all var(--transition);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 0 0 3px rgba(51, 174, 244, 0.25);
}
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
    border-radius: var(--radius);
    font-weight: 500;
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-dark {
    background: var(--dark);
    border-color: var(--dark);
    border-radius: var(--radius);
    font-weight: 500;
}
.btn-dark:hover {
    background: #0f172a;
}
.btn-light {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}
.btn-danger {
    border-radius: var(--radius);
}

/* ---- Forms ---- */
.form-control {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.6rem 0.85rem;
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--card-bg);
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(51, 174, 244, 0.15);
}
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--dark);
    margin-bottom: 0.4rem;
}
.form-text, .form-label .text-muted {
    color: var(--muted) !important;
}

/* ---- Tables ---- */
.table {
    border-collapse: separate;
    border-spacing: 0;
}
.table thead th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--secondary);
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}
.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}
.table tbody tr:hover {
    background: var(--primary-50);
}
.table-striped tbody tr:nth-of-type(odd) {
    background: #fafbfc;
}
.table-striped tbody tr:nth-of-type(odd):hover {
    background: var(--primary-50);
}

/* ---- Tabs ---- */
.nav-tabs {
    border-bottom: 2px solid var(--border-color);
    gap: 0.25rem;
}
.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--secondary);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
    margin-bottom: -2px;
    transition: all var(--transition);
    border-radius: 0;
}
.nav-tabs .nav-link:hover {
    color: var(--primary);
    border-bottom-color: rgba(51, 174, 244, 0.3);
    background: transparent;
}
.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
    font-weight: 600;
}

/* ---- Badges / Pills ---- */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success {
    background: #ecfdf5;
    color: #065f46;
}
.badge-danger {
    background: #fef2f2;
    color: #991b1b;
}
.badge-warning {
    background: #fffbeb;
    color: #92400e;
}
.badge-info {
    background: #e8f6fe;
    color: #1a6d9e;
}

/* ---- Status dots ---- */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.success { background: var(--success); }
.status-dot.danger { background: var(--danger); }
.status-dot.warning { background: var(--warning); }
.status-dot.info { background: var(--info); }

/* ---- DataTables overrides ---- */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--radius) !important;
    margin: 0 2px;
}
div.dataTables_processing {
    background: var(--dark) !important;
    color: #fff !important;
    border-radius: var(--radius-lg) !important;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
}

/* DataTables sort icons */
table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
    cursor: pointer;
    position: relative;
    padding-right: 1.75rem !important;
}
table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--muted);
}
table.dataTable thead th.sorting::after {
    content: "\2195";
    opacity: 0.4;
}
table.dataTable thead th.sorting_asc::after {
    content: "\2191";
    color: var(--primary);
    opacity: 1;
}
table.dataTable thead th.sorting_desc::after {
    content: "\2193";
    color: var(--primary);
    opacity: 1;
}
table.dataTable thead th.sorting:hover::after {
    opacity: 0.8;
}

/* ---- Login page ---- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8f6fe 0%, #d0edfc 50%, #f1f5f9 100%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 2.5rem;
}
.login-card .login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}
.login-card .login-logo img {
    height: 48px;
    width: auto;
}
.login-card .login-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    color: var(--dark);
    margin-bottom: 0.25rem;
}
.login-card .login-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* ---- Breadcrumb / back link ---- */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: color var(--transition);
    margin-bottom: 1rem;
}
.back-link:hover {
    color: var(--primary);
}

/* ---- Section divider ---- */
.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* ---- Overview meta items ---- */
.meta-item {
    margin-bottom: 1rem;
}
.meta-item .meta-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.15rem;
}
.meta-item .meta-value {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.95rem;
}

/* ---- Select2 overrides ---- */
.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    min-height: 42px;
    padding: 0.2rem 0.4rem;
}
.select2-container--default .select2-selection--multiple:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(51, 174, 244, 0.15);
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: var(--primary-light);
    border: 1px solid #a8ddfb;
    border-radius: 4px;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--primary);
}
.select2-dropdown {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

/* ---- Dropdown overrides ---- */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 0.35rem;
}
.dropdown-item {
    border-radius: 0.35rem;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
}
.dropdown-item:hover {
    background: var(--primary-light);
}

/* ---- Checkbox/Radio refinements ---- */
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}
.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(51, 174, 244, 0.2);
    border-color: var(--primary);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ---- Utility ---- */
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .page-wrapper {
        padding: 1rem;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}
