/* ============================================================
   SalonCRM — app.css
   Stack: Bootstrap 5.3 + custom
   ============================================================ */

/* ── Fonts & Variables ──────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --sidebar-width: 240px;
    --topbar-height: 60px;

    --color-bg:       #f4f5f7;
    --color-surface:  #ffffff;
    --color-border:   #e2e5ea;
    --color-text:     #1a1f2e;
    --color-muted:    #6b7280;

    --color-primary:  #1a56db;
    --color-primary-hover: #1648c7;
    --color-success:  #0e9f6e;
    --color-warning:  #e3a008;
    --color-danger:   #e02424;
    --color-info:     #0694a2;

    --color-sidebar-bg:     #0f1923;
    --color-sidebar-text:   #c9d3df;
    --color-sidebar-hover:  #1e2d3d;
    --color-sidebar-active: #1a56db;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.10);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.12);

    --font-brand: 'Bebas Neue', sans-serif;
    --font-body:  'Inter', -apple-system, sans-serif;

    --transition: 0.2s ease;
}

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

body {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

/* ── Auth Layout ─────────────────────────────────────────── */
.auth-body {
    background: linear-gradient(135deg, #0f1923 0%, #1a2d42 50%, #0f1923 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-icon {
    font-size: 42px;
    display: block;
    margin-bottom: 8px;
}

.auth-title {
    font-family: var(--font-brand);
    font-size: 36px;
    letter-spacing: 2px;
    color: var(--color-text);
    margin: 0 0 4px;
}

.auth-subtitle {
    color: var(--color-muted);
    font-size: 13px;
    margin: 0;
}

.auth-hint { text-align: center; }
.auth-hint code {
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
}

/* ── App Layout ─────────────────────────────────────────── */
.app-body {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.brand-logo { font-size: 22px; }

.brand-name {
    font-family: var(--font-brand);
    font-size: 22px;
    letter-spacing: 2px;
    color: #ffffff;
    line-height: 1;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    font-size: 13.5px;
    font-weight: 500;
    position: relative;
}

.nav-item i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: #ffffff;
}

.nav-item.active {
    background: var(--color-sidebar-active);
    color: #ffffff;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: #60a5fa;
    border-radius: 0 2px 2px 0;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}

.user-role {
    font-size: 11px;
    color: var(--color-muted);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
}

/* ── Main Wrapper ────────────────────────────────────────── */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--color-text);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.topbar-branch { flex: 1; }

.branch-selector {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: border-color var(--transition);
}
.branch-selector:hover { border-color: var(--color-primary); }
.branch-selector::after { margin-left: 8px; }

.branch-name-static {
    font-size: 13px;
    color: var(--color-muted);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-user-btn {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text);
    font-weight: 500;
    transition: border-color var(--transition);
}
.topbar-user-btn:hover { border-color: var(--color-primary); }
.topbar-user-btn::after { margin-left: 4px; }

.topbar-avatar {
    width: 28px;
    height: 28px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 24px;
    overflow: auto;
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--color-text);
}

.page-subtitle {
    color: var(--color-muted);
    font-size: 13px;
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--color-border);
    padding: 14px 18px;
    font-weight: 600;
}

.card-body { padding: 18px; }

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

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

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.bg-primary-soft { background: #eff6ff; }
.bg-success-soft { background: #f0fdf4; }
.bg-warning-soft { background: #fffbeb; }
.bg-danger-soft  { background: #fef2f2; }
.bg-info-soft    { background: #ecfeff; }

.stat-value {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-text);
}

.stat-label {
    font-size: 12px;
    color: var(--color-muted);
    margin-top: 2px;
}

/* ── Dashboard branch card ───────────────────────────────── */
.dashboard-branch-card { transition: box-shadow var(--transition); }
.dashboard-branch-card:hover { box-shadow: var(--shadow-md); }

/* ── Tables ──────────────────────────────────────────────── */
.table {
    margin: 0;
    font-size: 13.5px;
}

.table th {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--color-muted);
    padding: 10px 14px;
    white-space: nowrap;
}

.table td {
    padding: 10px 14px;
    vertical-align: middle;
    border-color: var(--color-border);
}

.table-hover tbody tr:hover {
    background: #f9fafb;
    cursor: pointer;
}

/* ── Status Badges ───────────────────────────────────────── */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: .2px;
}

.status-pending     { background: #fef3c7; color: #92400e; }
.status-confirmed   { background: #dbeafe; color: #1e40af; }
.status-in_progress { background: #fef9c3; color: #713f12; }
.status-completed   { background: #d1fae5; color: #065f46; }
.status-cancelled   { background: #fee2e2; color: #991b1b; }
.status-no_show     { background: #f3f4f6; color: #6b7280; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    font-size: 13.5px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.btn-lg { padding: 10px 20px; font-size: 15px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-control, .form-select {
    border-color: var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--color-text);
}

.input-group-text {
    background: #f9fafb;
    border-color: var(--color-border);
    color: var(--color-muted);
    font-size: 14px;
}

/* ── Modals ──────────────────────────────────────────────── */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--color-border);
    padding: 16px 20px;
}

.modal-title { font-weight: 700; font-size: 16px; }

.modal-footer {
    border-top: 1px solid var(--color-border);
    padding: 12px 20px;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast {
    min-width: 280px;
    border-radius: var(--radius-md);
    border: none;
    box-shadow: var(--shadow-lg);
}

.toast.success { background: #065f46; color: #fff; }
.toast.error   { background: #991b1b; color: #fff; }
.toast.warning { background: #92400e; color: #fff; }
.toast.info    { background: #1e40af; color: #fff; }

.toast .btn-close { filter: invert(1); }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-muted);
}
.empty-state i {
    font-size: 36px;
    display: block;
    margin-bottom: 12px;
    opacity: .4;
}
.empty-state p { margin: 0; font-size: 14px; }

/* ── Dropdown ────────────────────────────────────────────── */
.dropdown-menu {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 13.5px;
    padding: 6px;
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    color: var(--color-text);
}

.dropdown-item:hover { background: #f3f4f6; }
.dropdown-item.active { background: var(--color-primary); color: #fff; }
.dropdown-divider { border-color: var(--color-border); margin: 4px 0; }

/* ── Calendar ────────────────────────────────────────────── */
.calendar-wrapper {
    overflow-x: auto;
}

.calendar-grid {
    display: grid;
    gap: 0;
    min-width: 600px;
}

.calendar-time-col {
    width: 60px;
    flex-shrink: 0;
}

.calendar-header {
    display: flex;
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 10;
    border-bottom: 2px solid var(--color-border);
}

.calendar-time-header {
    width: 64px;
    min-width: 64px;
    padding: 10px 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    border-right: 1px solid var(--color-border);
}

.calendar-master-header {
    flex: 1;
    min-width: 130px;
    padding: 10px 12px;
    text-align: center;
    border-right: 1px solid var(--color-border);
    background: var(--color-surface);
}

.calendar-master-header:last-child { border-right: none; }
.calendar-master-name { font-weight: 600; font-size: 13px; }
.calendar-master-sub  { font-size: 11px; color: var(--color-muted); }

.calendar-body { position: relative; }

.calendar-row {
    display: flex;
    border-bottom: 1px solid #f1f3f5;
    min-height: 40px;
}

.calendar-row:hover { background: #fafbfc; }

.calendar-time-cell {
    width: 64px;
    min-width: 64px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 11px;
    color: var(--color-muted);
    border-right: 1px solid var(--color-border);
    background: #fafbfc;
    flex-shrink: 0;
}

.calendar-slot {
    flex: 1;
    min-width: 130px;
    border-right: 1px solid #f1f3f5;
    position: relative;
    cursor: pointer;
    transition: background var(--transition);
}

.calendar-slot:last-child { border-right: none; }

.calendar-slot:hover { background: #f0f7ff; }

.calendar-slot.unavailable {
    background: repeating-linear-gradient(
        45deg,
        #f8f9fa,
        #f8f9fa 4px,
        #f1f3f5 4px,
        #f1f3f5 8px
    );
    cursor: not-allowed;
}

.calendar-slot.unavailable:hover { background: repeating-linear-gradient(
    45deg, #f8f9fa, #f8f9fa 4px, #f1f3f5 4px, #f1f3f5 8px
); }

/* Appointment blocks */
.appt-block {
    position: absolute;
    left: 2px; right: 2px;
    border-radius: 5px;
    padding: 4px 7px;
    font-size: 11.5px;
    overflow: hidden;
    cursor: pointer;
    z-index: 2;
    transition: opacity var(--transition), box-shadow var(--transition);
    border-left: 3px solid rgba(0,0,0,.2);
}

.appt-block:hover { opacity: .9; box-shadow: var(--shadow-md); }

.appt-block.status-confirmed   { background: #bfdbfe; color: #1e3a8a; border-left-color: #3b82f6; }
.appt-block.status-in_progress { background: #fef08a; color: #713f12; border-left-color: #eab308; }
.appt-block.status-completed   { background: #bbf7d0; color: #14532d; border-left-color: #22c55e; }
.appt-block.status-cancelled   { background: #fecaca; color: #7f1d1d; border-left-color: #ef4444; }
.appt-block.status-pending     { background: #e0e7ff; color: #3730a3; border-left-color: #6366f1; }
.appt-block.status-no_show     { background: #f3f4f6; color: #6b7280; border-left-color: #9ca3af; }

.appt-client { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-services { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .8; }

/* ── Schedule Table ──────────────────────────────────────── */
.schedule-table th, .schedule-table td {
    text-align: center;
    white-space: nowrap;
    padding: 7px 5px;
    font-size: 12.5px;
}

.schedule-cell {
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.schedule-cell:hover { background: #eff6ff; }
.schedule-cell.has-shift { background: #d1fae5; color: #065f46; font-weight: 500; }
.schedule-cell.is-dayoff { background: #fee2e2; color: #991b1b; }
.schedule-cell.today-col { background: #fffbeb; }

/* ── Salary Table ────────────────────────────────────────── */
.salary-table th { background: #f9fafb; }
.salary-total-row { background: #f0f7ff; font-weight: 700; }

/* ── Finance ─────────────────────────────────────────────── */
.cashdesk-card {
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.cashdesk-card .amount {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
}

/* ── Client Card ─────────────────────────────────────────── */
.client-stat { text-align: center; }
.client-stat .val { font-size: 22px; font-weight: 700; }
.client-stat .lbl { font-size: 11px; color: var(--color-muted); text-transform: uppercase; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 13.5px;
    padding: 10px 14px;
}
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-success { background: #f0fdf4; color: #166534; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info    { background: #eff6ff; color: #1e40af; }

/* ── Spinner / Loading ───────────────────────────────────── */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

/* ── Search & Filter Bar ─────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}

.filter-bar .form-control,
.filter-bar .form-select {
    max-width: 200px;
}

/* ── Pagination ──────────────────────────────────────────── */
.pagination .page-link {
    border-color: var(--color-border);
    color: var(--color-text);
    font-size: 13px;
    padding: 5px 10px;
}

.pagination .page-item.active .page-link {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .topbar-toggle {
        display: block;
    }

    .main-content {
        padding: 16px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-value { font-size: 16px; }

    .filter-bar .form-control,
    .filter-bar .form-select {
        max-width: 100%;
        flex: 1;
    }

    .topbar { padding: 0 12px; gap: 10px; }
}

@media (max-width: 576px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .page-actions { width: 100%; }
}

/* ── Utilities ───────────────────────────────────────────── */
.text-money { font-variant-numeric: tabular-nums; }
.fw-600 { font-weight: 600; }
.cursor-pointer { cursor: pointer; }
.no-select { user-select: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sidebar active link detection */
.nav-item[data-page].active {
    background: var(--color-sidebar-active);
    color: #fff;
}
