/* CareConnect - Main Stylesheet */
/* Aesthetic: Warm, clinical-meets-human, calm greens and cream */

:root {
    --sage: #5a7a5c;
    --sage-light: #7a9e7d;
    --sage-pale: #e8f0e9;
    --sage-dark: #3d5a3f;
    --cream: #faf8f4;
    --warm-white: #ffffff;
    --text-dark: #1e2d1f;
    --text-mid: #4a5e4c;
    --text-light: #7a907c;
    --border: #d4e0d5;
    --shadow: rgba(60, 80, 62, 0.10);
    --warning: #c8833a;
    --warning-pale: #fdf0e2;
    --danger: #b84545;
    --danger-pale: #fdeaea;
    --info: #3a7ab8;
    --info-pale: #e6f0fd;
    --success: #4a8c55;
    --success-pale: #eaf4ec;
    --sidebar-w: 260px;
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--cream);
    color: var(--text-dark);
    display: flex;
    min-height: 100vh;
    font-size: 14.5px;
    line-height: 1.6;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sage-dark);
    color: #d8ebd9;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo-icon { font-size: 28px; }
.logo-name {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}
.logo-sub { font-size: 11px; color: rgba(255,255,255,0.5); letter-spacing: 0.5px; }

.nav-section { padding: 20px 12px 8px; }
.nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    padding: 0 8px;
    margin-bottom: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s;
    margin-bottom: 2px;
}
.nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-link.active { background: var(--sage-light); color: #fff; font-weight: 500; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
    margin-top: auto;
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    margin-bottom: 8px;
}
.user-avatar {
    width: 36px; height: 36px;
    background: var(--sage-light);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px; color: #fff;
    flex-shrink: 0;
}
.user-name { font-size: 13.5px; color: #fff; font-weight: 500; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); }

.sidebar-btn {
    display: block;
    text-align: center;
    padding: 7px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    margin-bottom: 4px;
    transition: all 0.2s;
}
.sidebar-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-btn-logout { color: #f8a9a9; }
.sidebar-btn-logout:hover { background: rgba(220,60,60,0.2); color: #ff9999; }

/* ── MAIN LAYOUT ── */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--warm-white);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-mid);
    padding: 4px 8px;
}

.page-title {
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
    flex: 1;
}

.date-display {
    font-size: 13px;
    color: var(--text-light);
    white-space: nowrap;
}

.main-content {
    padding: 28px;
    flex: 1;
}

/* ── CARDS ── */
.card {
    background: var(--warm-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px var(--shadow);
}

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

.card-title {
    font-family: 'Playfair Display', serif;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-dark);
}

/* ── STAT CARDS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--warm-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 4px var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px var(--shadow); }

.stat-icon {
    font-size: 28px;
    width: 50px; height: 50px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    flex-shrink: 0;
}
.stat-icon-green { background: var(--sage-pale); }
.stat-icon-orange { background: var(--warning-pale); }
.stat-icon-red { background: var(--danger-pale); }
.stat-icon-blue { background: var(--info-pale); }

.stat-value {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
}
.stat-label { font-size: 12.5px; color: var(--text-light); margin-top: 2px; }

/* ── TABLES ── */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    background: var(--sage-pale);
    color: var(--sage-dark);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 11px 16px;
    text-align: left;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
tbody tr:hover { background: #f5fbf5; }
tbody tr:last-child { border-bottom: none; }

tbody td {
    padding: 12px 16px;
    color: var(--text-dark);
    vertical-align: middle;
}

/* ── FORMS ── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-mid);
    letter-spacing: 0.3px;
}

.form-group label .required { color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"],
input[type="tel"], select, textarea {
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-dark);
    background: var(--warm-white);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(90,122,92,0.12);
}

textarea { resize: vertical; min-height: 80px; }

.form-section {
    margin-bottom: 28px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; margin-bottom: 0; }
.form-section-title {
    font-family: 'Playfair Display', serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--sage-dark);
    margin-bottom: 16px;
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--sage); color: #fff; }
.btn-primary:hover { background: var(--sage-dark); color: #fff; }
.btn-secondary { background: var(--sage-pale); color: var(--sage-dark); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f3535; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; border-radius: 5px; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--sage);
    color: var(--sage);
}
.btn-outline:hover { background: var(--sage); color: #fff; }

.btn-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── BADGES ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-active { background: var(--success-pale); color: var(--success); }
.badge-inactive, .badge-discharged { background: #f0f0f0; color: #666; }
.badge-admin { background: #ede8fa; color: #5c4a9a; }
.badge-nurse { background: var(--info-pale); color: var(--info); }
.badge-carer { background: var(--sage-pale); color: var(--sage-dark); }
.badge-manager { background: var(--warning-pale); color: var(--warning); }
.badge-hr { background: #fce8f3; color: #8c3a72; }
.badge-warning { background: var(--warning-pale); color: var(--warning); }
.badge-danger { background: var(--danger-pale); color: var(--danger); }
.badge-success { background: var(--success-pale); color: var(--success); }
.badge-info { background: var(--info-pale); color: var(--info); }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-approved { background: var(--success-pale); color: var(--success); }
.badge-rejected { background: var(--danger-pale); color: var(--danger); }

/* ── ALERTS ── */
.alert {
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    position: relative;
}
.alert-success { background: var(--success-pale); color: var(--success); border: 1px solid #b2d9b8; }
.alert-error, .alert-danger { background: var(--danger-pale); color: var(--danger); border: 1px solid #f0b8b8; }
.alert-warning { background: var(--warning-pale); color: var(--warning); border: 1px solid #f5c990; }
.alert-info { background: var(--info-pale); color: var(--info); border: 1px solid #aed0f5; }
.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.7;
    color: inherit;
    flex-shrink: 0;
}

/* ── PATIENT CARD ── */
.patient-card {
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.patient-card:hover { border-color: var(--sage); box-shadow: 0 4px 12px var(--shadow); transform: translateY(-1px); }

.patient-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.patient-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.patient-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    background: var(--sage-pale);
    flex-shrink: 0;
    font-weight: 700;
    color: var(--sage-dark);
}
.patient-name { font-weight: 600; font-size: 15px; }
.patient-meta { font-size: 12.5px; color: var(--text-light); }

.patient-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    font-size: 12.5px;
}
.patient-detail-label { color: var(--text-light); }
.patient-detail-val { color: var(--text-dark); font-weight: 500; }

/* ── PAGINATION ── */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
}
.page-link {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    text-decoration: none;
    color: var(--text-mid);
    font-size: 13px;
    transition: all 0.2s;
}
.page-link:hover, .page-link.active { background: var(--sage); border-color: var(--sage); color: #fff; }

/* ── TABS ── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab {
    padding: 10px 18px;
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    text-decoration: none;
    border: 2px solid transparent;
    border-bottom: none;
    transition: all 0.2s;
    position: relative;
    bottom: -2px;
}
.tab:hover { color: var(--sage); }
.tab.active {
    color: var(--sage-dark);
    border-color: var(--border);
    border-bottom: 2px solid var(--warm-white);
    background: var(--warm-white);
}

/* ── SEARCH BAR ── */
.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.search-input {
    flex: 1;
    min-width: 200px;
    padding: 9px 14px 9px 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--warm-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a907c' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") 10px center no-repeat;
}
.search-input:focus { outline: none; border-color: var(--sage); }

/* ── ROTA GRID ── */
.rota-grid {
    overflow-x: auto;
}
.rota-table th { min-width: 100px; }
.shift-early { background: #ddf0e8; color: #2d6e4c; }
.shift-late { background: #fff0d8; color: #8a5c00; }
.shift-night { background: #e8e0f5; color: #4a3678; }
.shift-day { background: #d8ecf5; color: #2a5d7a; }
.shift-off { background: #f5f5f5; color: #888; }
.shift-cell {
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

/* ── LOGIN PAGE ── */
.login-page {
    min-height: 100vh;
    background: var(--sage-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--warm-white);
    border-radius: 20px;
    padding: 48px 44px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo-icon { font-size: 42px; display: block; margin-bottom: 8px; }
.login-logo-name {
    font-family: 'Playfair Display', serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--sage-dark);
}
.login-logo-sub { color: var(--text-light); font-size: 13px; margin-top: 2px; }
.login-form .form-group { margin-bottom: 16px; }
.login-form .btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; margin-top: 8px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 12px; color: var(--text-light); }

/* ── ACTIVITY TIMELINE ── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
    content: '';
    position: absolute;
    left: 10px; top: 0; bottom: 0;
    width: 2px;
    background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
    position: absolute;
    left: -22px;
    top: 6px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--sage);
    border: 3px solid var(--warm-white);
    box-shadow: 0 0 0 2px var(--sage-pale);
}
.timeline-dot-warning { background: var(--warning); }
.timeline-dot-danger { background: var(--danger); }
.timeline-content {
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}
.timeline-time { font-size: 11.5px; color: var(--text-light); margin-bottom: 4px; }
.timeline-text { font-size: 13.5px; }

/* ── DASHBOARD GRID ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.dashboard-grid .col-span-2 { grid-column: span 2; }

/* ── MISC ── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.text-sm { font-size: 12.5px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.flex-1 { flex: 1; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.section-title {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
}
.section-sub { font-size: 13px; color: var(--text-light); margin-top: 2px; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}
.empty-state-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state-text { font-size: 15px; margin-bottom: 14px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .main-wrapper { margin-left: 0; }
    .menu-toggle { display: block; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-grid .col-span-2 { grid-column: span 1; }
    .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
    .col-span-2, .col-span-3 { grid-column: span 1; }
    .main-content { padding: 16px; }
}
