/* =====================================================
   Family Medical Information System - Main Stylesheet
   Fully Responsive - Mobile / Tablet / Desktop
   ===================================================== */

:root {
    --primary:       #1a6fc4;
    --primary-dark:  #155a9e;
    --secondary:     #2ec4b6;
    --success:       #28a745;
    --danger:        #dc3545;
    --warning:       #ffc107;
    --info:          #17a2b8;
    --light:         #f8f9fa;
    --dark:          #343a40;
    --sidebar-width: 260px;
    --header-height: 60px;
    --card-radius:   12px;
    --shadow:        0 2px 15px rgba(0,0,0,0.08);
    --shadow-hover:  0 5px 25px rgba(0,0,0,0.15);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f4f8;
    color: #333;
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
}

/* =====================================================
   LOGIN
   ===================================================== */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a6fc4 0%, #2ec4b6 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff; border-radius: 20px;
    padding: 40px 36px; width: 100%; max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo { text-align: center; margin-bottom: 28px; }

.login-logo .app-icon {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, #1a6fc4, #2ec4b6);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 14px;
    font-size: 30px; color: #fff;
}

.login-logo h2 { color: var(--primary); font-weight: 700; font-size: 21px; }
.login-logo p  { color: #888; margin: 4px 0 0; font-size: 13px; }

/* =====================================================
   LAYOUT
   ===================================================== */
.app-wrapper { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1a2744 0%, #1a4a8a 100%);
    position: fixed; top: 0; left: 0;
    height: 100vh; overflow-y: auto;
    z-index: 1000;
    transition: transform 0.28s ease;
    display: flex; flex-direction: column;
}

.sidebar-brand {
    padding: 18px 20px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-brand .brand-icon {
    width: 38px; height: 38px;
    background: rgba(255,255,255,0.2); border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 17px; margin-right: 10px; vertical-align: middle;
}

.sidebar-brand h5 {
    color: #fff; font-size: 14px; font-weight: 700;
    display: inline-block; vertical-align: middle; margin: 0;
}

.sidebar-brand small {
    color: rgba(255,255,255,0.45); font-size: 11px;
    display: block; margin-left: 48px; margin-top: 2px;
}

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

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

.sidebar-user .user-info .name { color: #fff; font-size: 13px; font-weight: 600; }
.sidebar-user .user-info .role { color: rgba(255,255,255,0.5); font-size: 11px; }

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

.nav-section {
    padding: 5px 20px 3px;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; color: rgba(255,255,255,0.35);
    letter-spacing: 1px; margin-top: 10px;
}

.sidebar-nav a {
    display: flex; align-items: center;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none; font-size: 13.5px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: #fff; border-left-color: var(--secondary);
}

.sidebar-nav a i { width: 22px; font-size: 15px; margin-right: 10px; flex-shrink: 0; }

/* OVERLAY */
.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s, visibility 0.28s;
}
.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* HAMBURGER */
.hamburger {
    display: none;
    flex-direction: column; justify-content: center; align-items: center;
    width: 38px; height: 38px;
    background: #f0f4f8; border: none; border-radius: 8px;
    cursor: pointer; gap: 5px; flex-shrink: 0;
    transition: background 0.2s;
}

.hamburger span {
    display: block; width: 20px; height: 2px;
    background: #444; border-radius: 2px;
    transition: all 0.28s; transform-origin: center;
}

.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.hamburger:hover { background: #e2e8f0; }

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1; display: flex; flex-direction: column; min-width: 0;
}

/* TOPBAR */
.topbar {
    height: var(--header-height);
    background: #fff; border-bottom: 1px solid #e8ecf0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    gap: 10px;
}

.topbar .page-title {
    font-size: 17px; font-weight: 700; color: var(--dark);
    margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

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

.topbar-actions .btn-logout {
    background: none; border: 1px solid #e0e0e0;
    padding: 6px 12px; border-radius: 8px;
    color: #666; cursor: pointer; font-size: 13px;
    transition: all 0.2s; white-space: nowrap;
    text-decoration: none;
    display: inline-flex; align-items: center; gap: 5px;
}
.topbar-actions .btn-logout:hover { background: #dc3545; border-color: #dc3545; color: #fff; }

.content-area { padding: 20px; flex: 1; }

/* =====================================================
   GRID
   ===================================================== */
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
[class^="col-"], [class*=" col-"] { padding: 0 8px; }
.col-12 { width: 100%; }
.col-8  { width: 66.67%; }
.col-6  { width: 50%; }
.col-4  { width: 33.33%; }
.col-3  { width: 25%; }
.col-2  { width: 16.67%; }

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: #fff; border-radius: var(--card-radius);
    box-shadow: var(--shadow); border: none;
    margin-bottom: 20px; overflow: hidden;
}

.card-header {
    padding: 14px 20px; border-bottom: 1px solid #f0f0f0;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px; background: #fff;
}

.card-header h5 { margin: 0; font-size: 14px; font-weight: 700; color: var(--dark); }
.card-header h5 i { color: var(--primary); margin-right: 7px; }
.card-body { padding: 20px; }

/* =====================================================
   STAT CARDS
   ===================================================== */
.stat-card {
    background: #fff; border-radius: var(--card-radius);
    padding: 18px; display: flex; align-items: center; gap: 14px;
    box-shadow: var(--shadow); transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 16px;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

.stat-icon {
    width: 54px; height: 54px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}

.stat-icon.blue   { background: rgba(26,111,196,0.12); color: var(--primary); }
.stat-icon.teal   { background: rgba(46,196,182,0.12); color: var(--secondary); }
.stat-icon.green  { background: rgba(40,167,69,0.12);  color: var(--success); }
.stat-icon.orange { background: rgba(255,193,7,0.12);  color: #e67e00; }
.stat-icon.red    { background: rgba(220,53,69,0.12);  color: var(--danger); }

.stat-info .number { font-size: 26px; font-weight: 800; color: var(--dark); line-height: 1; }
.stat-info .label  { font-size: 12px; color: #888; margin-top: 3px; }

/* =====================================================
   MEMBER CARDS
   ===================================================== */
.member-card {
    background: #fff; border-radius: var(--card-radius);
    padding: 20px; text-align: center;
    box-shadow: var(--shadow); transition: all 0.25s;
    cursor: pointer; border: 2px solid transparent;
    position: relative; margin-bottom: 16px;
}
.member-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--primary); }

.member-photo {
    width: 80px; height: 80px; border-radius: 50%; object-fit: cover;
    margin: 0 auto 10px; display: block; border: 3px solid #e8ecf0;
}

.member-photo-placeholder {
    width: 80px; height: 80px; border-radius: 50%;
    background: linear-gradient(135deg, #1a6fc4, #2ec4b6);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 10px; font-size: 28px; color: #fff; font-weight: 700;
}

.member-card h6 { font-size: 14px; font-weight: 700; margin: 0 0 4px; }
.member-card .rel-badge {
    display: inline-block; padding: 2px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 600;
    background: rgba(26,111,196,0.1); color: var(--primary);
}

.member-card .blood-group {
    display: inline-block; width: 32px; height: 32px;
    border-radius: 50%; background: #dc3545; color: #fff;
    font-size: 10px; font-weight: 700;
    line-height: 32px; text-align: center;
    position: absolute; top: 10px; right: 10px;
}

/* =====================================================
   FORMS
   ===================================================== */
.form-control, .form-select {
    border: 1.5px solid #e0e6ed; border-radius: 8px;
    padding: 9px 13px; font-size: 13.5px;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%; background: #fff;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,111,196,0.12);
    outline: none;
}

.form-label { font-weight: 600; font-size: 13px; color: #555; margin-bottom: 5px; display: block; }
.form-group  { margin-bottom: 16px; }
textarea.form-control { min-height: 85px; resize: vertical; }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    padding: 8px 18px; border-radius: 8px;
    font-size: 13.5px; font-weight: 600;
    border: none; cursor: pointer; transition: all 0.2s;
    display: inline-flex; align-items: center; gap: 6px;
    text-decoration: none; white-space: nowrap;
}

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover   { background: var(--primary-dark); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover   { background: #218838; color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-danger:hover    { background: #c82333; color: #fff; }
.btn-warning   { background: var(--warning); color: #212529; }
.btn-warning:hover   { background: #e0a800; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #545b62; color: #fff; }
.btn-info      { background: var(--info); color: #fff; }
.btn-outline-primary { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-danger  { background: transparent; border: 1.5px solid var(--danger); color: var(--danger); }
.btn-outline-danger:hover  { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* =====================================================
   TABLES
   ===================================================== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    background: #f8f9fa; padding: 11px 14px;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    color: #888; letter-spacing: 0.5px;
    border-bottom: 2px solid #e8ecf0; white-space: nowrap;
}

.data-table td {
    padding: 11px 14px; border-bottom: 1px solid #f0f0f0;
    vertical-align: middle; font-size: 13.5px;
}
.data-table tr:hover td { background: #f8fbff; }

/* =====================================================
   BADGES
   ===================================================== */
.badge {
    padding: 3px 9px; border-radius: 20px;
    font-size: 11px; font-weight: 600; display: inline-block;
}
.badge-success   { background: rgba(40,167,69,0.15);  color: var(--success); }
.badge-danger    { background: rgba(220,53,69,0.15);  color: var(--danger); }
.badge-warning   { background: rgba(255,193,7,0.15);  color: #856404; }
.badge-info      { background: rgba(23,162,184,0.15); color: var(--info); }
.badge-primary   { background: rgba(26,111,196,0.15); color: var(--primary); }
.badge-secondary { background: rgba(108,117,125,0.15);color: #6c757d; }

/* =====================================================
   ALERTS
   ===================================================== */
.alert {
    padding: 11px 16px; border-radius: 8px; font-size: 13px;
    margin-bottom: 14px;
    display: flex; align-items: flex-start; gap: 9px;
}
.alert-success { background: rgba(40,167,69,0.1);  color: #155724; border-left: 4px solid var(--success); }
.alert-danger  { background: rgba(220,53,69,0.1);  color: #721c24; border-left: 4px solid var(--danger); }
.alert-info    { background: rgba(23,162,184,0.1); color: #0c5460; border-left: 4px solid var(--info); }
.alert-warning { background: rgba(255,193,7,0.1);  color: #856404; border-left: 4px solid var(--warning); }

/* =====================================================
   UPLOAD / DOCS
   ===================================================== */
.upload-zone {
    border: 2px dashed #c8d6e5; border-radius: 10px;
    padding: 22px; text-align: center; background: #f8fbff;
    transition: all 0.2s; cursor: pointer;
}
.upload-zone:hover { border-color: var(--primary); background: #eef4fb; }
.upload-zone i { font-size: 32px; color: var(--primary); margin-bottom: 8px; display: block; }
.upload-zone p { color: #888; margin: 0; font-size: 13px; }

.doc-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; background: #f8f9fa;
    border-radius: 8px; margin-bottom: 8px;
    border: 1px solid #e8ecf0; flex-wrap: wrap;
}
.doc-item .doc-icon    { font-size: 20px; flex-shrink: 0; }
.doc-item .doc-details { flex: 1; min-width: 0; }
.doc-item .doc-heading { font-weight: 700; font-size: 13px; color: var(--dark); }
.doc-item .doc-meta    { font-size: 11px; color: #999; margin-top: 2px; }

/* =====================================================
   PROFILE HEADER
   ===================================================== */
.profile-header {
    background: linear-gradient(135deg, #1a2744, #1a6fc4);
    border-radius: var(--card-radius); padding: 24px;
    color: #fff; display: flex; align-items: center; gap: 22px;
    margin-bottom: 20px; flex-wrap: wrap;
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }

.profile-avatar {
    width: 100px; height: 100px; border-radius: 50%; object-fit: cover;
    border: 4px solid rgba(255,255,255,0.3);
}

.profile-avatar-placeholder {
    width: 100px; height: 100px; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; color: #fff; font-weight: 700;
    border: 4px solid rgba(255,255,255,0.3);
}

.profile-info h3   { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.profile-info .sub { color: rgba(255,255,255,0.75); font-size: 13px; }
.profile-info .tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 7px; }

.profile-tag {
    background: rgba(255,255,255,0.15); color: #fff;
    padding: 3px 11px; border-radius: 20px; font-size: 11px; font-weight: 600;
}

/* =====================================================
   TABS
   ===================================================== */
.tab-nav {
    display: flex; flex-wrap: wrap;
    border-bottom: 2px solid #e8ecf0;
    margin-bottom: 20px; gap: 4px;
}
.tab-btn {
    padding: 9px 18px; border: none; background: none;
    font-size: 13px; font-weight: 600; color: #888;
    cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all 0.2s;
    border-radius: 6px 6px 0 0;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); background: rgba(26,111,196,0.05); }
.tab-btn:hover  { color: var(--primary); }
.tab-content    { display: none; }
.tab-content.active { display: block; }

/* =====================================================
   SEVERITY
   ===================================================== */
.severity-mild     { background: rgba(40,167,69,0.15);  color: var(--success); }
.severity-moderate { background: rgba(255,193,7,0.15);  color: #856404; }
.severity-severe   { background: rgba(220,53,69,0.15);  color: var(--danger); }
.severity-critical { background: #dc3545; color: #fff; }

/* =====================================================
   UTILITIES
   ===================================================== */
.section-divider { border: none; border-top: 1px solid #e8ecf0; margin: 22px 0; }
.text-muted  { color: #999 !important; font-size: 13px; }
.required    { color: var(--danger); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.w-100 { width: 100%; }
.d-flex { display: flex; }
.align-items-center     { align-items: center; }
.justify-content-between{ justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 10px; } .gap-3 { gap: 15px; }
.mt-1{margin-top:5px;}.mt-2{margin-top:10px;}.mt-3{margin-top:15px;}
.mb-1{margin-bottom:5px;}.mb-2{margin-bottom:10px;}.mb-3{margin-bottom:15px;}

/* =====================================================
   RESPONSIVE — TABLET  (≤ 991px)
   ===================================================== */
@media (max-width: 991px) {

    .hamburger { display: flex; }

    .sidebar { transform: translateX(-100%); }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.25);
    }

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

    .topbar { padding: 0 14px; }
    .topbar .page-title { font-size: 15px; }

    .content-area { padding: 14px; }

    /* Grid: 8-col → full, 6 → 50%, 4 → 50%, 3 → 50% */
    .col-8 { width: 100%; }
    .col-4 { width: 50%; }
    .col-3 { width: 50%; }

    .profile-info h3 { font-size: 19px; }
}

/* =====================================================
   RESPONSIVE — MOBILE  (≤ 600px)
   ===================================================== */
@media (max-width: 600px) {

    .topbar {
        height: auto; min-height: 54px;
        padding: 8px 12px; flex-wrap: wrap;
    }
    .topbar .page-title { font-size: 14px; }

    /* Hide date text on small screens */
    .topbar-actions span { display: none; }

    .content-area { padding: 10px; }

    /* All columns stack */
    .col-2,.col-3,.col-4,.col-6,.col-8,.col-12 { width: 100%; }

    .card-header { padding: 12px 14px; }
    .card-body   { padding: 14px; }

    .stat-card  { padding: 14px; gap: 12px; }
    .stat-icon  { width: 46px; height: 46px; font-size: 18px; }
    .stat-info .number { font-size: 22px; }

    .profile-header { flex-direction: column; text-align: center; padding: 16px; }
    .profile-avatar, .profile-avatar-placeholder { width: 80px; height: 80px; font-size: 28px; }
    .profile-info .tags { justify-content: center; }
    .profile-info h3 { font-size: 17px; }

    .member-photo, .member-photo-placeholder { width: 65px; height: 65px; font-size: 22px; }
    .member-card h6 { font-size: 12px; }

    /* Prevent iOS input zoom */
    .form-control, .form-select { font-size: 16px; }

    .btn    { padding: 8px 14px; font-size: 13px; }
    .btn-sm { padding: 5px 10px; font-size: 11px; }

    .table-responsive { margin: 0 -10px; padding: 0 10px; }

    .tab-nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
    .tab-btn { white-space: nowrap; padding: 8px 13px; font-size: 12px; }

    .upload-zone { padding: 16px; }
    .upload-zone i { font-size: 26px; }

    .login-card { padding: 28px 18px; border-radius: 14px; }
}

/* =====================================================
   RESPONSIVE — SMALL PHONES  (≤ 380px)
   ===================================================== */
@media (max-width: 380px) {
    .content-area { padding: 8px; }
    .stat-info .number { font-size: 20px; }
    .topbar-actions .btn-logout .fa-sign-out-alt + * { display: none; }
}
