/* HomeScout — Mobile-first responsive CSS
   Design language adapted from Agent Scout */

:root {
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --primary-light: rgba(102,126,234,0.08);
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --danger: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
    --bg: #f8f9fc;
    --bg-alt: #f0f2f5;
    --text: #1a1a2e;
    --text-muted: #666;
    --border: #e9ecef;
    --white: #ffffff;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease-in; }

/* --- Sidebar --- */
.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.user-role { font-size: 0.7rem; color: rgba(102,126,234,0.85); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }

.nav-links {
    list-style: none;
    flex: 1;
    padding: 0.75rem 0;
}

.nav-links li a {
    display: block;
    padding: 0.625rem 1.25rem;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-links li a:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.9);
}

.nav-links li a.active {
    background: rgba(102,126,234,0.15);
    color: var(--white);
    border-left-color: #667eea;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
}

.user-name { color: rgba(255,255,255,0.8); font-weight: 500; }
.logout-link { color: rgba(255,255,255,0.4); text-decoration: none; font-size: 0.8125rem; transition: color 0.2s; }
.logout-link:hover { color: var(--white); }

/* --- Main Content --- */
.content {
    margin-left: 240px;
    padding: 2rem;
    flex: 1;
    max-width: 1200px;
}

.content-full {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
}

/* --- Auth --- */
.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.auth-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    padding: 2.5rem;
}

.auth-card h1 {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.75rem;
}

.auth-link {
    text-align: center;
    font-size: 0.875rem;
    margin-top: 1.25rem;
    color: var(--text-muted);
}

.auth-link a { color: var(--primary); font-weight: 500; text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

/* --- Page Header --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); }

/* --- Cards --- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: transform 0.3s, box-shadow 0.3s;
}

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

.card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.75rem; color: var(--text); }

.card-form { max-width: 600px; }

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem 1.25rem;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.375rem; font-weight: 500; }

/* --- Grid Layouts --- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.inline-form { display: inline; }
.inline { display: inline; }

.input-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: auto;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    background: var(--white);
    transition: all 0.2s;
    line-height: 1.5;
}

.btn:hover {
    background: var(--bg-alt);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--white);
    border-color: transparent;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

.btn-full { display: block; width: 100%; text-align: center; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }

.quick-links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* --- Tables --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table tbody tr:hover { background: var(--bg); }

.data-table-sm th,
.data-table-sm td {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
}

.data-table a { color: var(--primary); text-decoration: none; font-weight: 500; }
.data-table a:hover { text-decoration: underline; }

.row-disabled { opacity: 0.5; }

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 0.1875rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-active, .badge-scheduled, .badge-new, .badge-completed, .badge-interested, .badge-appointment_set {
    background: #dcfce7;
    color: #166534;
}

.badge-trialing { background: #fff3cd; color: #856404; }

.badge-inactive, .badge-suspended, .badge-cancelled, .badge-do_not_call, .badge-not_interested {
    background: #fee2e2;
    color: #991b1b;
}

.badge-pending, .badge-callback, .badge-voicemail, .badge-rescheduled, .badge-processing {
    background: #fef9c3;
    color: #854d0e;
}

.badge-contacted, .badge-confirmed, .badge-no_answer, .badge-wrong_number {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-super_admin { background: #fae8ff; color: #86198f; }
.badge-admin { background: #e0e7ff; color: #3730a3; }
.badge-franchise_owner { background: #dcfce7; color: #166534; }
.badge-team_lead { background: #fef9c3; color: #854d0e; }
.badge-agent { background: #f1f5f9; color: #475569; }

.badge-past_due { background: #fee2e2; color: #991b1b; }

/* --- Alerts --- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar input,
.filter-bar select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.pagination a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.pagination a:hover { text-decoration: underline; }

/* --- Tags --- */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    background: var(--primary-light);
    border-radius: 6px;
    font-size: 0.8125rem;
    color: var(--primary);
    font-weight: 500;
}

.tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.tag-remove:hover { color: var(--danger); }

/* --- Detail List --- */
.detail-list { font-size: 0.875rem; }
.detail-list dt { font-weight: 600; color: var(--text-muted); margin-top: 0.5rem; }
.detail-list dd { margin-left: 0; }

/* --- Nav List --- */
.nav-list { list-style: none; }
.nav-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: var(--text);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: background 0.2s;
}
.nav-list li a:hover { background: var(--bg-alt); }
.nav-list li a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* --- Script Steps --- */
.script-step-view {
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--primary);
    margin-bottom: 0.75rem;
    background: var(--primary-light);
    border-radius: 0 8px 8px 0;
}
.script-step-view h4 { margin-bottom: 0.5rem; font-size: 0.9375rem; font-weight: 600; }
.script-step-view p { color: var(--text); font-size: 0.875rem; }
.script-step-view details { margin-top: 0.5rem; font-size: 0.8125rem; }
.script-step-view summary { cursor: pointer; color: var(--primary); font-weight: 500; }

/* --- Utilities --- */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mb-1 { margin-bottom: 0.5rem; }
small.text-muted { display: block; margin-top: 0.25rem; font-size: 0.75rem; }
a { color: var(--primary); }

/* --- Calendar --- */
.cal-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.cal-nav-title {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    text-align: center;
    min-width: 180px;
}
.cal-legend {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.cal-legend-item { font-size: 0.8125rem; font-weight: 500; display: flex; align-items: center; gap: 0.25rem; }
.cal-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }
.cal-grid-wrap { overflow-x: auto; }
.cal-grid {
    display: grid;
    min-width: 600px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.cal-corner, .cal-corner-sub { background: var(--bg-alt); }
.cal-day-header {
    background: var(--bg-alt);
    font-weight: 600;
    font-size: 0.8125rem;
    text-align: center;
    padding: 0.5rem 0;
    border-left: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.cal-today-header { background: rgba(102,126,234,0.12); color: var(--primary); }
.cal-est-header {
    text-align: center;
    border-left: 1px solid rgba(255,255,255,0.3);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}
.cal-est-name {
    font-size: 0.65rem;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.cal-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
    padding-right: 6px;
    border-bottom: 1px solid #f0f0f0;
    line-height: 30px;
    background: var(--bg-alt);
}
.cal-cell {
    border-bottom: 1px solid #f0f0f0;
    border-right: 1px solid #f5f5f5;
    background: var(--white);
    min-height: 30px;
}
.cal-cell-hour { border-bottom-color: var(--border); }
.cal-cell-day-start { border-left: 1px solid var(--border); }
.cal-today-col { background: rgba(102,126,234,0.04); }
.cal-cell[onclick] { cursor: pointer; }
.cal-cell[onclick]:hover { background: rgba(102,126,234,0.08); }
.cal-selected { background: rgba(102,126,234,0.15) !important; }

/* Appointment blocks */
.cal-appt {
    z-index: 2;
    border-radius: 4px;
    color: #fff;
    padding: 2px 4px;
    overflow: hidden;
    font-size: 0.7rem;
    line-height: 1.3;
    margin: 1px;
    cursor: default;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.cal-appt-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-appt-time { opacity: 0.85; font-size: 0.65rem; }

/* Pick mode confirmation bar (below calendar) */
.cal-confirm-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
}
.cal-confirm-info { font-size: 0.9rem; color: #1e40af; }
.cal-confirm-actions { display: flex; gap: 0.5rem; }

/* Calendar selection summary (active call page) */
.cal-selection-summary {
    padding: 0.5rem 0.75rem;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #166534;
    margin-top: 0.5rem;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        background: #1a1a2e;
        z-index: 100;
    }

    .sidebar-header { display: none; }
    .sidebar-footer { display: none; }

    .nav-links {
        display: flex;
        padding: 0;
        white-space: nowrap;
    }

    .nav-links li a {
        padding: 0.875rem 1rem;
        font-size: 0.75rem;
        border-left: none;
        border-top: 3px solid transparent;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .nav-links li a.active {
        border-left: none;
        border-top-color: #667eea;
        background: rgba(102,126,234,0.15);
    }

    .content {
        margin-left: 0;
        margin-bottom: 4rem;
        padding: 1.25rem;
    }

    .content-full {
        padding: 1rem;
    }

    .auth-card {
        padding: 2rem;
    }

    .grid-2 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .data-table { font-size: 0.8125rem; }
    .data-table th, .data-table td { padding: 0.5rem; }

    .page-header h1 { font-size: 1.25rem; }

    .stat-card:hover { transform: none; }
    .card:hover { box-shadow: var(--shadow); }
    .btn:hover { transform: none; }
    .btn-primary:hover { transform: none; }

    .cal-nav { font-size: 0.8125rem; }
    .cal-nav-title { font-size: 0.875rem; }
    .cal-grid { min-width: 500px; }
    .cal-est-name { font-size: 0.55rem; }
    .cal-confirm-bar { flex-direction: column; gap: 0.5rem; text-align: center; }
}
