/* ============================================================
   Enterprise Design System — Call Accounting & Reporting
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --- CSS Custom Properties --- */
:root {
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Palette */
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-primary-light: #eef2ff;
    --color-primary-50: #e0e7ff;
    --color-accent: #818cf8;
    --color-danger: #ef4444;
    --color-danger-hover: #dc2626;
    --color-success: #10b981;
    --color-warning: #f59e0b;

    /* Gradient */
    --gradient-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-vibrant: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);

    /* Neutrals */
    --color-bg: #f1f5f9;
    --color-surface: #ffffff;
    --color-surface-alt: #f8fafc;
    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;

    /* Text */
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;

    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.15);
    --shadow-card: 0 4px 20px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);

    /* Header */
    --header-bg: linear-gradient(135deg, #312e81 0%, #4c1d95 100%);
    --header-text: #f8fafc;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font-family);
    background: var(--gradient-bg);
    background-attachment: fixed;
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.6;
}

/* --- Layout --- */
.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Top Navigation Bar --- */
header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 0 24px;
    margin-bottom: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

header .header-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    gap: 16px;
}

header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}

header .brand img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
    background: white;
    padding: 2px;
}

header .brand-text h1 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
    color: #fff;
}

header .brand-text .subtitle {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    font-weight: 400;
    line-height: 1.2;
    margin: 0;
}

header .header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

header .header-user {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

header .header-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08);
    color: #cbd5e1;
    font-family: inherit;
}

header .header-btn:hover {
    background: rgba(255,255,255,0.18);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

header .header-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* --- Page Shell --- */
.page-body {
    padding: 28px 0 40px;
}

/* --- Card Component --- */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: none;
    overflow: hidden;
}

.card-body {
    padding: 28px 32px;
}

/* --- Stepper Wizard (Reports page) --- */
.stepper {
    display: flex;
    align-items: center;
    padding: 20px 32px;
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
    border-bottom: 1px solid var(--color-border);
    gap: 0;
}

.stepper-step {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 4px;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.stepper-step .step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    border: 2px solid var(--color-border-strong);
    color: var(--color-text-muted);
    background: var(--color-surface);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.stepper-step .step-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-text-muted);
    transition: color 0.2s ease;
    white-space: nowrap;
}

.stepper-step .step-desc {
    font-size: 0.73rem;
    color: var(--color-text-muted);
    font-weight: 400;
}

.stepper-step.active .step-number {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-color: #6366f1;
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.stepper-step.active .step-label {
    color: var(--color-text);
}

.stepper-step.completed .step-number {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #10b981;
    color: white;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

.stepper-step.completed .step-label {
    color: var(--color-text-secondary);
}

.stepper-connector {
    flex: 1;
    height: 2px;
    background: var(--color-border);
    margin: 0 16px;
    min-width: 40px;
    border-radius: 2px;
    transition: background 0.2s;
}

.stepper-connector.completed {
    background: var(--color-success);
}

/* --- Tab Content --- */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

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

/* --- Collapsible Filter Sections --- */
.filter-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    background: var(--color-surface);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.filter-section:hover {
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
    border-color: #c7d2fe;
}

.filter-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    background: var(--color-surface-alt);
    border-bottom: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}

.filter-section-header:hover {
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
}

.filter-section.open .filter-section-header {
    border-bottom-color: var(--color-border);
}

.filter-section-header h3 {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.filter-section-header h3 svg {
    width: 16px;
    height: 16px;
    color: var(--color-primary);
    flex-shrink: 0;
}

.filter-section-header .chevron {
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.filter-section.open .filter-section-header .chevron {
    transform: rotate(180deg);
}

.filter-section-body {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.filter-section.open .filter-section-body {
    padding: 18px 20px;
    max-height: 600px;
}

/* --- Section (legacy, used inside filter bodies) --- */
.section {
    margin-bottom: 0;
    padding: 0;
    background: none;
    border-radius: 0;
    border-left: none;
}

.section h3 {
    color: var(--color-text);
    margin-bottom: 14px;
    font-size: 0.95rem;
    font-weight: 600;
}

/* --- Form Controls --- */
.radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.radio-group.vertical {
    flex-direction: column;
    gap: 4px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--color-text);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    transition: all 0.15s ease;
    user-select: none;
}

.radio-group label:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.radio-group label:has(input:checked) {
    border-color: #818cf8;
    background: linear-gradient(135deg, #eef2ff, #ede9fe);
    color: #4f46e5;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.15);
}

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

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    font-size: 0.85rem;
}

.filter-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary);
    border-radius: 3px;
}

.filter-select,
.filter-input,
.full-width {
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: inherit;
    transition: all 0.15s ease;
    width: 100%;
    background: var(--color-surface);
    color: var(--color-text);
}

.filter-select:enabled,
.filter-input:enabled {
    border-color: var(--color-border-strong);
    background: var(--color-surface);
}

.filter-select:disabled,
.filter-input:disabled {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    cursor: not-allowed;
    border-color: var(--color-border);
}

.filter-select:focus,
.filter-input:focus,
.full-width:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* --- Date / Time / Number inputs --- */
.datetime-filters {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-row > label {
    min-width: 140px;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.date-range,
.time-range,
.duration-range {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
}

.date-range label,
.time-range label,
.duration-range label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

input[type="date"],
input[type="time"],
input[type="number"] {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: inherit;
    transition: all 0.15s ease;
    background: var(--color-surface);
    color: var(--color-text);
}

input[type="date"]:enabled,
input[type="time"]:enabled,
input[type="number"]:enabled {
    border-color: var(--color-border-strong);
}

input[type="date"]:disabled,
input[type="time"]:disabled,
input[type="number"]:disabled {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

input[type="date"]:focus,
input[type="time"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* --- Action Buttons --- */
.action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 0;
    padding: 20px 32px;
    border-top: 1px solid var(--color-border);
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}

.btn {
    padding: 10px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border-strong);
}

.btn-secondary:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

.btn-danger-outline {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
}

.btn-danger-outline:hover {
    background: #fef2f2;
}

/* --- Loading Overlay --- */
.loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay.hidden { display: none; }

.loading-overlay p {
    color: white;
    font-size: 1rem;
    margin-top: 16px;
    font-weight: 500;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Report Type Cards --- */
.report-type-group {
    margin-bottom: 24px;
}

.report-type-group h4 {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

.report-type-group .radio-group.vertical label {
    border: 1px solid var(--color-border);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 0;
}

.report-type-group .radio-group.vertical label:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.report-type-group .radio-group.vertical label:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    html { font-size: 14px; }

    header .header-inner { height: 54px; }
    header .brand-text h1 { font-size: 0.95rem; }

    .card-body { padding: 20px; }

    .stepper { padding: 14px 20px; flex-wrap: wrap; gap: 8px; }
    .stepper-connector { display: none; }

    .filter-grid { grid-template-columns: 1fr; }
    .filter-row { flex-direction: column; align-items: flex-start; }

    .action-buttons {
        flex-direction: column;
        padding: 16px 20px;
    }

    .btn { width: 100%; justify-content: center; }

    .radio-group { flex-direction: column; }
}
