/**
 * FLOWGUARD — Refined Minimal Greyscale Design System
 * Professional healthcare SaaS with subtle sophistication
 * Font: Inter | Palette: Near-greyscale with blue accent
 */

/* ============================================
   CSS VARIABLES — Design Tokens
   ============================================ */
:root {
    /* Layout */
    --fg-sidebar-w: 260px;
    --fg-topbar-h: 64px;
    
    /* Greyscale Foundation */
    --grey-50: #fafafa;
    --grey-100: #f5f5f5;
    --grey-200: #e5e5e5;
    --grey-300: #d4d4d4;
    --grey-400: #a3a3a3;
    --grey-500: #737373;
    --grey-600: #525252;
    --grey-700: #404040;
    --grey-800: #262626;
    --grey-900: #171717;
    --grey-950: #0a0a0a;
    
    /* Blue Accent (subtle, refined) */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-900: #1e3a8a;
    
    /* Semantic Colors */
    --color-bg: var(--grey-50);
    --color-surface: #ffffff;
    --color-border: var(--grey-200);
    --color-border-subtle: var(--grey-100);
    --color-text: var(--grey-900);
    --color-text-secondary: var(--grey-600);
    --color-text-tertiary: var(--grey-400);
    --color-primary: var(--blue-600);
    --color-primary-hover: var(--blue-700);
    
    /* Shadows (refined, subtle) */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   GLOBAL RESET & BASE
   ============================================ */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--color-bg);
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    overflow-x: hidden;
    letter-spacing: -0.011em;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-hover);
}

/* ============================================
   SIDEBAR — Refined Dark
   ============================================ */
.fg-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--fg-sidebar-w);
    background: var(--grey-950);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-base);
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.fg-sidebar::-webkit-scrollbar {
    width: 6px;
}

.fg-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.fg-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Brand Header */
.fg-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: opacity var(--transition-fast);
}

.fg-sidebar-brand:hover {
    opacity: 0.9;
}

.fg-brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--grey-800), var(--grey-700));
    display: grid;
    place-items: center;
    color: #ffffff;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: var(--shadow-xs);
}

.fg-sidebar-brand span {
    font-weight: 600;
    font-size: 16px;
    color: #ffffff;
    letter-spacing: -0.02em;
}

/* Navigation */
.fg-sidebar-nav {
    flex: 1;
    padding: 8px 12px;
}

.fg-nav-group {
    padding: 20px 12px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.3);
}

.fg-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.fg-nav-link i {
    width: 18px;
    text-align: center;
    font-size: 16px;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.fg-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.9);
}

.fg-nav-link:hover i {
    opacity: 1;
}

.fg-nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-weight: 600;
}

.fg-nav-link.active i {
    opacity: 1;
}

/* Sidebar Footer */
.fg-sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
}

/* Mobile Sidebar Overlay */
.fg-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.fg-sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 991px) {
    .fg-sidebar {
        transform: translateX(-100%);
    }
    
    .fg-sidebar.show {
        transform: translateX(0);
    }
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
.fg-main {
    margin-left: var(--fg-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-base);
}

@media (max-width: 991px) {
    .fg-main {
        margin-left: 0;
    }
}

/* ============================================
   TOPBAR — Clean & Minimal
   ============================================ */
.fg-topbar {
    height: var(--fg-topbar-h);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-subtle);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
}

.fg-topbar .breadcrumb {
    margin: 0;
    background: transparent;
    padding: 0;
}

.fg-topbar .breadcrumb-item {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.fg-topbar .breadcrumb-item.active {
    color: var(--color-text);
    font-weight: 500;
}

.fg-topbar .breadcrumb-item + .breadcrumb-item::before {
    color: var(--color-text-tertiary);
    content: "→";
    padding: 0 8px;
}

/* Avatar */
.fg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--grey-900);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.01em;
}

/* ============================================
   CONTENT AREA
   ============================================ */
.fg-content {
    flex: 1;
    padding: 32px;
}

@media (max-width: 768px) {
    .fg-content {
        padding: 20px 16px;
    }
}

/* ============================================
   PAGE HEADER
   ============================================ */
.fg-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
}

.fg-page-header h1 {
    font-size: 28px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.fg-page-header h1 i {
    color: var(--color-text-secondary);
    font-size: 24px;
}

@media (max-width: 768px) {
    .fg-page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .fg-page-header h1 {
        font-size: 24px;
    }
}

/* ============================================
   CARDS — Clean & Refined
   ============================================ */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition-fast);
}

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

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--color-border-subtle);
    padding: 16px 20px;
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.card-body {
    padding: 20px;
}

/* ============================================
   BUTTONS — Minimal with Purpose
   ============================================ */
.btn {
    font-family: inherit;
    font-weight: 500;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    letter-spacing: -0.01em;
}

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

.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.btn-outline-primary:hover {
    background: var(--color-primary);
    color: white;
}

.btn-outline-secondary {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

.btn-outline-secondary:hover {
    background: var(--grey-100);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary {
    background: var(--grey-100);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background: var(--grey-200);
    color: var(--color-text);
}

.btn-success {
    background: var(--grey-800);
    color: white;
    border-color: var(--grey-800);
}

.btn-success:hover {
    background: var(--grey-900);
    color: white;
}

.btn-warning {
    background: #fbbf24;
    color: #78350f;
    border-color: #fbbf24;
}

.btn-warning:hover {
    background: #f59e0b;
    color: #78350f;
}

.btn-danger,
.btn-outline-danger {
    background: transparent;
    color: var(--grey-600);
    border-color: var(--grey-300);
}

.btn-danger:hover,
.btn-outline-danger:hover {
    background: var(--grey-100);
    color: var(--grey-800);
    border-color: var(--grey-400);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    border: none;
    background: transparent;
}

.btn-link:hover {
    color: var(--color-text);
}

.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

.btn-group .btn:last-child {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

/* ============================================
   FORMS — Clean Input Design
   ============================================ */
.form-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--color-text);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.form-control,
.form-select {
    font-family: inherit;
    font-size: 14px;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

.form-control::placeholder {
    color: var(--color-text-tertiary);
}

.form-control-sm,
.form-select-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.form-check-input {
    border-color: var(--color-border);
}

.form-check-input:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.form-check-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-switch .form-check-input {
    width: 42px;
    height: 22px;
    cursor: pointer;
}

.form-text {
    font-size: 12px;
    color: var(--color-text-secondary);
}

textarea.form-control {
    resize: vertical;
}

.input-group-text {
    background: var(--grey-50);
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}

/* ============================================
   TABLES — Minimal & Readable
   ============================================ */
.table {
    font-size: 14px;
    color: var(--color-text);
}

.table thead th {
    background: transparent;
    border-bottom: 2px solid var(--color-border-subtle);
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: middle;
}

.table-hover tbody tr {
    cursor: pointer;
    transition: background var(--transition-fast);
}

.table-hover tbody tr:hover {
    background: var(--grey-50);
}

.table-responsive {
    border-radius: 8px;
}

/* ============================================
   BADGES — Greyscale Status System
   ============================================ */
.badge {
    font-weight: 500;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 0.01em;
}

/* Status Badges (greyscale with subtle tints) */
.badge-sent {
    background: var(--grey-100);
    color: var(--grey-700);
}

.badge-contacted {
    background: var(--blue-50);
    color: var(--blue-700);
}

.badge-scheduled {
    background: var(--blue-100);
    color: var(--blue-700);
}

.badge-confirmed {
    background: var(--grey-200);
    color: var(--grey-800);
}

.badge-completed {
    background: var(--grey-800);
    color: white;
}

.badge-cancelled {
    background: var(--grey-100);
    color: var(--grey-600);
}

.badge-no_show {
    background: var(--grey-300);
    color: var(--grey-800);
}

.badge-dropped {
    background: var(--grey-100);
    color: var(--grey-500);
}

/* Risk Badges (subtle amber for high-risk, grey for others) */
.badge-risk-low {
    background: var(--grey-100);
    color: var(--grey-600);
}

.badge-risk-med {
    background: var(--grey-200);
    color: var(--grey-700);
}

.badge-risk-hig {
    background: #fef3c7;
    color: #92400e;
}

/* Alert Severity (subtle color hints) */
.badge-info {
    background: var(--blue-50);
    color: var(--blue-700);
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-critical {
    background: var(--grey-800);
    color: white;
}

.badge-secondary {
    background: var(--grey-100);
    color: var(--grey-700);
}

/* ============================================
   STAT CARDS — Dashboard Metrics
   ============================================ */
.fg-stat {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-fast);
}

.fg-stat:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.fg-stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.fg-stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 4px;
}

.fg-stat-sub {
    font-size: 13px;
    color: var(--color-text-tertiary);
}

/* Stat Color Variants (subtle) */
.fg-stat.blue .fg-stat-value {
    color: var(--blue-600);
}

.fg-stat.green .fg-stat-value {
    color: var(--grey-900);
}

.fg-stat.red .fg-stat-sub {
    color: var(--grey-600);
}

/* ============================================
   ALERTS — System Messages
   ============================================ */
.alert {
    border-radius: 6px;
    border: 1px solid transparent;
    padding: 14px 16px;
    font-size: 14px;
}

.alert-success {
    background: var(--grey-50);
    border-color: var(--grey-200);
    color: var(--grey-900);
}

.alert-danger {
    background: var(--grey-50);
    border-color: var(--grey-300);
    color: var(--grey-900);
}

.alert-warning {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.alert-info {
    background: var(--blue-50);
    border-color: var(--blue-100);
    color: var(--blue-900);
}

.alert i {
    flex-shrink: 0;
}

.alert .btn-close {
    padding: 12px;
}

/* ============================================
   EMPTY STATES
   ============================================ */
.fg-empty {
    text-align: center;
    padding: 64px 32px;
    color: var(--color-text-tertiary);
}

.fg-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.fg-empty p {
    font-size: 15px;
    margin: 0;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-muted {
    color: var(--color-text-secondary) !important;
}

.text-green {
    color: var(--grey-900) !important;
}

.text-red {
    color: var(--grey-600) !important;
}

.text-success {
    color: var(--grey-800) !important;
}

.text-danger {
    color: var(--grey-700) !important;
}

.text-primary {
    color: var(--color-primary) !important;
}

.cursor-pointer {
    cursor: pointer;
}

.fw-semibold {
    font-weight: 600;
}

.small {
    font-size: 13px;
}

.bg-light {
    background-color: var(--grey-50) !important;
}

.bg-opacity-25 {
    opacity: 0.25;
}

.bg-opacity-10 {
    opacity: 0.1;
}

.border {
    border: 1px solid var(--color-border) !important;
}

.border-top {
    border-top: 1px solid var(--color-border) !important;
}

.border-bottom {
    border-bottom: 1px solid var(--color-border) !important;
}

.rounded {
    border-radius: 6px !important;
}

.font-monospace {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 13px;
}

/* ============================================
   FIELD LABELS (for view pages)
   ============================================ */
.fg-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.fg-value {
    font-size: 14px;
    color: var(--color-text);
}

/* ============================================
   DROPDOWN MENUS
   ============================================ */
.dropdown-menu {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
}

.dropdown-item {
    border-radius: 4px;
    font-size: 14px;
    padding: 8px 12px;
    color: var(--color-text);
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--grey-50);
    color: var(--color-text);
}

.dropdown-divider {
    margin: 8px 0;
    border-color: var(--color-border-subtle);
}

.dropdown-toggle::after {
    margin-left: 8px;
}

/* ============================================
   LIST GROUPS
   ============================================ */
.list-group-item {
    border-color: var(--color-border-subtle);
    font-size: 14px;
    transition: background var(--transition-fast);
}

.list-group-item-action {
    color: var(--color-text);
}

.list-group-item-action:hover {
    background: var(--grey-50);
    color: var(--color-text);
}

.list-group-flush .list-group-item {
    border-width: 0 0 1px;
}

/* ============================================
   NAV TABS
   ============================================ */
.nav-tabs {
    border-bottom: 1px solid var(--color-border-subtle);
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-secondary);
    padding: 12px 20px;
    font-weight: 500;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.nav-tabs .nav-link:hover {
    color: var(--color-text);
    border-bottom-color: var(--color-border);
}

.nav-tabs .nav-link.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: transparent;
}

/* ============================================
   MODAL OVERRIDES
   ============================================ */
.modal-content {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

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

.modal-title {
    font-weight: 600;
    font-size: 18px;
    color: var(--color-text);
}

.modal-body {
    padding: 20px;
}

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

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */
@media (max-width: 768px) {
    .fg-page-header h1 {
        font-size: 22px;
    }
    
    .fg-stat-value {
        font-size: 28px;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .fg-content {
        padding: 20px 16px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .fg-sidebar,
    .fg-topbar,
    .btn,
    .fg-page-header .d-flex {
        display: none !important;
    }
    
    .fg-main {
        margin-left: 0;
    }
    
    .card {
        box-shadow: none;
        page-break-inside: avoid;
    }
}
