/* ════════════════════════════════════════════════════════════
   🏥 RAINBOW HOSPITAL MANAGEMENT SYSTEM — Shared Stylesheet
   Extracted from mainmenu.php (matches your inventory app design)
   Colors: Dark Blue #1e3a8a, Yellow #facc15
   ════════════════════════════════════════════════════════════ */

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

body {
    font-family: Arial, sans-serif;
    background: #f9f9f9;
    color: #1f2937;
    font-size: 14px;
    line-height: 1.5;
}

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
    background: #1e3a8a;
    color: white;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.page-header h1 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.page-header .subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

/* ── CONTENT WRAPPER ─────────────────────────────────────── */
.content-wrap {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ── CARD ────────────────────────────────────────────────── */
.card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f0f4ff;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.card-header h2 {
    color: #1e3a8a;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.card-body { padding: 16px; }

/* ── FORMS (matches your mainmenu.php .form-row/.form-group) ── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 4px;
    color: #1e3a8a;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.form-group label .req { color: #dc2626; }
.form-group label .hint {
    font-weight: 400;
    color: #6b7280;
    text-transform: none;
    font-size: 11px;
    margin-left: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: 0.2s;
    outline: none;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.form-group input[readonly] {
    background: #f3f4f6;
    color: #6b7280;
}
.form-group .help-text {
    font-size: 11px;
    color: #6b7280;
    margin-top: 3px;
}
.form-group input.code-error {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220,38,38,0.2);
}
.form-group input.code-ok {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5,150,105,0.2);
}
.form-group.full { grid-column: 1 / -1; }

/* ── BUTTONS (matches your mainmenu.php .btn) ─────────────── */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: 0.15s;
    font-family: inherit;
}
.btn-blue   { background: #1e3a8a; color: white; }
.btn-blue:hover   { background: #1e40af; }
.btn-green  { background: #059669; color: white; }
.btn-green:hover  { background: #047857; }
.btn-gray   { background: #6b7280; color: white; }
.btn-gray:hover   { background: #4b5563; }
.btn-red    { background: #dc2626; color: white; }
.btn-red:hover    { background: #b91c1c; }
.btn-amber  { background: #d97706; color: white; }
.btn-amber:hover  { background: #b45309; }
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}
.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.btn-row .btn { flex: 1; justify-content: center; }

/* ── MODAL (matches your mainmenu.php modal) ──────────────── */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    overflow-y: auto;
}
.modal-content {
    background: #fff;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 680px;
    max-width: 94vw;
    max-height: 94vh;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}
.modal-content.size-sm { width: 440px; }
.modal-content.size-lg { width: 900px; }
.modal-header {
    padding: 18px 24px;
    background: #1e3a8a;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.modal-header h2 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-header .close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}
.modal-header .close-btn:hover { color: white; }
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* ── TABLE ────────────────────────────────────────────────── */
.table-wrap {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
th, td {
    border-bottom: 1px solid #e5e7eb;
    padding: 8px 10px;
    text-align: left;
}
th {
    background: #f0f4ff;
    color: #1e3a8a;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 2;
    font-weight: 700;
}
tr:hover { background: #f8fafc; }
td .code-badge {
    background: #f0f4ff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-family: monospace;
}

/* ── SEARCH BAR ──────────────────────────────────────────── */
.search-bar {
    position: relative;
    display: inline-block;
}
.search-bar input {
    padding: 8px 12px 8px 32px;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    width: 300px;
    max-width: 100%;
    outline: none;
}
.search-bar input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.search-bar .icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

/* ── TOAST NOTIFICATIONS ─────────────────────────────────── */
.toast {
    display: none;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 600;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.3s ease;
}
.toast.toast-show { display: flex; }
.toast-success { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.toast-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.toast-loading { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }
.toast-info    { background: #f0f9ff; color: #0c4a6e; border: 1px solid #7dd3fc; }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-green  { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-amber  { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-red    { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-blue   { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge-gray   { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }

/* ── DIVIDER & SECTION LABEL ─────────────────────────────── */
.divider {
    border: none;
    border-top: 2px solid #e5e7eb;
    margin: 20px 0 16px;
}
.section-label {
    color: #1e3a8a;
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── STAT CARDS ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.stat-card .icon-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.stat-card .label {
    font-size: 10px;
    text-transform: uppercase;
    color: #6b7280;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.stat-card .value {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}
.stat-card.blue   .icon-box { background: #1e3a8a; color: white; }
.stat-card.green  .icon-box { background: #059669; color: white; }
.stat-card.amber  .icon-box { background: #d97706; color: white; }
.stat-card.red    .icon-box { background: #dc2626; color: white; }

/* ── ANIMATIONS ──────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.6s linear infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.6; transform: scale(1.3); }
}
.pulse { animation: pulse 2s infinite; }

/* ── RESPONSIVE (mobile) ─────────────────────────────────── */
@media (max-width: 700px) {
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }
    .modal-content {
        width: 95% !important;
        max-width: 95vw;
        margin: 2% auto !important;
        max-height: 96vh;
    }
    .search-bar input { width: 100%; }
    table { font-size: 12px; }
    th, td { padding: 6px 8px; }
    .btn-sm { padding: 4px 6px; font-size: 10px; }
    .modal-header h2 { font-size: 14px; }
    .modal-body { padding: 16px; }
    .page-header { padding: 10px 12px; }
    .page-header h1 { font-size: 16px; }
    .content-wrap { padding: 12px; }
}
@media (max-width: 380px) {
    .page-header h1 { font-size: 14px; }
}

/* ════════════════════════════════════════════════════════════
   📱 MOBILE AUDIT ENHANCEMENTS (v2)
   Better touch targets, full-screen modals, stacked layouts.
   Applied at max-width: 700px — overrides the basic block above.
   ════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
    /* ── Body + page layout ── */
    body { font-size: 14px; }
    .content-wrap { padding: 10px; }

    /* ── Page headers stack vertically ── */
    .page-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px;
        padding: 12px;
    }
    .page-header > div:first-child { width: 100%; }
    .page-header h1 { font-size: 18px; }
    .page-header .subtitle { font-size: 12px; }
    .page-header > .btn,
    .page-header > a.btn,
    .page-header > div > .btn { width: 100%; justify-content: center; }

    /* ── Buttons: bigger touch targets (Apple/Google min = 44px) ── */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 10px 16px;
        font-size: 14px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
    .btn-sm {
        min-height: 36px;
        min-width: 36px;
        padding: 8px 12px;
        font-size: 12px;
    }
    /* Stack button rows vertically on narrow screens */
    .btn-row {
        flex-direction: column !important;
        gap: 8px;
    }
    .btn-row .btn { width: 100%; }

    /* ── Modals: near-full-screen ── */
    .modal {
        padding: 0 !important;
    }
    .modal-content {
        width: 96% !important;
        max-width: 96vw !important;
        margin: 2vh auto !important;
        max-height: 96vh;
        overflow-y: auto;
    }
    .modal-content.size-sm {
        width: 96% !important;
        max-width: 96vw !important;
    }
    .modal-header { padding: 12px 14px; }
    .modal-header h2 { font-size: 15px; }
    .modal-body { padding: 14px; }
    .close-btn { font-size: 22px; min-width: 44px; min-height: 44px; }

    /* ── Form rows: single column ── */
    .form-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
    .form-row .form-group { width: 100% !important; }
    .form-group.full { width: 100% !important; }
    input, select, textarea {
        min-height: 44px;
        font-size: 14px;
        padding: 10px 12px;
    }
    label { font-size: 12px; margin-bottom: 4px; }

    /* ── Stat cards: 2 per row on phones (1 per row on very narrow) ── */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
    .stat-card { padding: 10px; }
    .stat-card .value { font-size: 18px; }
    .stat-card .label { font-size: 10px; }
    .stat-card .icon-box { width: 32px; height: 32px; font-size: 14px; }
    @media (max-width: 400px) {
        .stats-grid { grid-template-columns: 1fr !important; }
    }

    /* ── Tables: scrollable with hint ── */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    .table-wrap::after {
        content: '← Swipe to see more →';
        display: block;
        text-align: center;
        font-size: 10px;
        color: #9ca3af;
        padding: 4px;
        font-style: italic;
    }
    table { font-size: 12px; min-width: 600px; }
    th { padding: 8px 6px; font-size: 11px; }
    td { padding: 8px 6px; }
    /* Make action buttons in tables easier to tap */
    td .btn-sm { margin: 2px; }

    /* ── Cards: less padding on mobile ── */
    .card { margin-bottom: 10px; }
    .card-header { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
    .card-header h2 { font-size: 14px; }
    .card-body { padding: 12px; }

    /* ── Toast: bottom-anchored, bigger ── */
    .toast {
        bottom: 10px !important;
        top: auto !important;
        left: 10px !important;
        right: 10px !important;
        max-width: none !important;
        font-size: 13px;
        padding: 12px 16px;
        min-height: 44px;
    }

    /* ── Badges: slightly bigger for readability ── */
    .badge { font-size: 11px; padding: 3px 8px; }

    /* ── Search bars: full width ── */
    .search-bar { flex-direction: column !important; gap: 8px; }
    .search-bar input,
    .search-bar select { width: 100% !important; }
}

/* ── Very narrow phones (≤ 400px) ── */
@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr !important; }
    .page-header h1 { font-size: 16px; }
    .modal-content { width: 100% !important; margin: 0 !important; border-radius: 0 !important; min-height: 100vh; }
}

/* ── WhatsApp share button (used in print windows) ── */
.share-btn-container {
    text-align: center;
    margin-top: 20px;
    padding: 16px;
    background: white;
}
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25D366;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    min-height: 44px;
    margin: 4px;
}
.share-btn:hover { background: #128C7E; }
.share-btn.print {
    background: #1e3a8a;
}
.share-btn.print:hover { background: #2563eb; }
.share-btn.close {
    background: #6b7280;
}
.share-btn.close:hover { background: #4b5563; }
