/* =========================================================
   GLOBAL RESET AND BASE
========================================================= */

:root {
    --primary: #7a1025;
    --primary-light: #a7193f;
    --primary-dark: #510c1c;

    --hospital-primary: #075b62;
    --hospital-dark: #054249;

    --page-bg: #eef2f7;
    --card-bg: #ffffff;

    --text-dark: #1d2a3a;
    --text-muted: #687486;

    --border-color: #e2e7ee;

    --sidebar-width: 270px;
    --topbar-height: 72px;

    --shadow-light:
        0 8px 24px rgba(26, 48, 82, 0.09);

    --shadow-medium:
        0 12px 34px rgba(26, 48, 82, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f7fb;
    color: var(--text-dark);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

/* =========================================================
   HOME PAGE HEADER
========================================================= */

.site-header {
    padding: 24px 6%;
    background:
        linear-gradient(
            135deg,
            var(--primary),
            var(--primary-light)
        );
    color: #ffffff;
    box-shadow:
        0 4px 18px rgba(0, 0, 0, 0.18);
}

.site-header h1 {
    margin: 0 0 6px;
    font-size: 30px;
}

.site-header p {
    margin: 0;
    opacity: 0.88;
}

/* =========================================================
   HOME PAGE LAYOUT
========================================================= */

.home-layout {
    display: grid;
    grid-template-columns: 1.35fr 0.85fr;
    gap: 28px;
    min-height: calc(100vh - 150px);
    padding: 32px 6%;
}

.letters-panel,
.login-card,
.content-card,
.welcome-box,
.install-card {
    border-radius: 18px;
    background: var(--card-bg);
    box-shadow: var(--shadow-medium);
}

/* =========================================================
   IMPORTANT LETTERS
========================================================= */

.letters-panel {
    overflow: hidden;
    padding: 0;
}

.panel-heading {
    padding: 20px 24px;
    border-bottom: 1px solid #efd3dc;
    background: #f8e9ee;
}

.panel-heading h2 {
    margin: 0 0 4px;
    color: var(--primary);
}

.panel-heading span {
    color: #667085;
    font-size: 13px;
}

.letters-scroll {
    height: 470px;
    overflow: hidden;
}

.letters-track {
    animation: verticalScroll 25s linear infinite;
}

.letters-scroll:hover .letters-track {
    animation-play-state: paused;
}

.letter-card {
    padding: 20px 24px;
    border-bottom: 1px solid #edf0f4;
    background: #ffffff;
}

.letter-card h3 {
    margin: 10px 0 14px;
    line-height: 1.5;
}

.letter-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: #6c7580;
    font-size: 13px;
}

@keyframes verticalScroll {

    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-50%);
    }
}

/* =========================================================
   LOGIN PAGE
========================================================= */

.login-panel {
    display: flex;
    align-items: center;
}

.login-card {
    width: 100%;
    padding: 34px;
}

.login-icon {
    text-align: center;
    font-size: 54px;
}

.login-card h2 {
    margin: 8px 0;
    text-align: center;
}

.login-card > p {
    color: var(--text-muted);
    text-align: center;
}

label {
    display: block;
    margin: 16px 0 7px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #ccd4df;
    border-radius: 10px;
    background: #ffffff;
    font-size: 15px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #8d1730;
    box-shadow:
        0 0 0 3px rgba(141, 23, 48, 0.12);
}

.password-wrap {
    position: relative;
}

.password-wrap input {
    padding-right: 75px;
}

.show-password {
    position: absolute;
    top: 7px;
    right: 8px;
    padding: 7px 10px;
    border: 0;
    border-radius: 7px;
    background: #eef1f5;
    cursor: pointer;
}

/* =========================================================
   BUTTONS
========================================================= */

.btn {
    display: inline-block;
    padding: 10px 16px;
    border: 0;
    border-radius: 9px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition:
        background 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: #8b1630;
    color: #ffffff;
}

.btn-primary:hover {
    background: #6f1025;
    box-shadow:
        0 6px 16px rgba(122, 16, 37, 0.23);
}

.btn-secondary {
    background: #edf1f6;
    color: #27394d;
}

.btn-secondary:hover {
    background: #dfe5ed;
}

.btn-danger {
    background: #c13535;
    color: #ffffff;
}

.btn-danger:hover {
    background: #a92626;
}

.btn-block {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
}

/* =========================================================
   ALERTS
========================================================= */

.alert {
    margin: 15px 0;
    padding: 12px 14px;
    border-radius: 9px;
}

.alert-error {
    background: #ffe7e7;
    color: #9c1b1b;
}

.alert-success {
    background: #e8f8ec;
    color: #176a31;
}

.security-note {
    margin-top: 18px;
    padding: 12px;
    border-radius: 8px;
    background: #f5f7fa;
    color: #667085;
    font-size: 13px;
}

footer {
    padding: 18px;
    color: #6c7680;
    text-align: center;
}

/* =========================================================
   OLD DASHBOARD COMPATIBILITY
========================================================= */

.dashboard-body {
    min-height: 100vh;
    background: var(--page-bg);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 5%;
    background: var(--primary);
    color: #ffffff;
    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.15);
}

.topbar div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.topbar span {
    font-size: 13px;
    opacity: 0.85;
}

.dashboard-container {
    padding: 28px 5%;
}

.welcome-box {
    margin-bottom: 22px;
    padding: 24px;
}

.welcome-box h1 {
    margin: 0 0 8px;
}

.welcome-box p {
    margin: 0;
    color: var(--text-muted);
}

/* =========================================================
   FIXED SIDEBAR
========================================================= */

.sidebar-layout {
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--page-bg);
}

.fixed-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1100;

    display: flex;
    flex-direction: column;

    width: var(--sidebar-width);

    background:
        linear-gradient(
            180deg,
            var(--primary) 0%,
            var(--primary-dark) 100%
        );

    color: #f9edf1;

    box-shadow:
        5px 0 20px rgba(27, 34, 48, 0.18);
}

.hospital-sidebar {
    background:
        linear-gradient(
            180deg,
            var(--hospital-primary) 0%,
            var(--hospital-dark) 100%
        );
}

/* =========================================================
   SIDEBAR HEADER
========================================================= */

.sidebar-header {
    position: relative;

    display: flex;
    align-items: center;
    gap: 12px;

    min-height: 78px;
    padding: 15px 18px;

    border-bottom:
        1px solid rgba(255, 255, 255, 0.13);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 44px;

    width: 44px;
    height: 44px;

    border-radius: 13px;

    background:
        rgba(255, 255, 255, 0.14);

    font-size: 25px;
}

.sidebar-brand {
    min-width: 0;
}

.sidebar-brand strong {
    display: block;

    color: #ffffff;
    font-size: 18px;
    line-height: 1.25;
}

.sidebar-brand span {
    display: block;

    margin-top: 3px;

    color: #d9aeb9;
    font-size: 11px;
}

.hospital-sidebar .sidebar-brand span {
    color: #b8e1e3;
}

.sidebar-close {
    display: none;

    position: absolute;
    top: 15px;
    right: 12px;

    width: 36px;
    height: 36px;
    padding: 0;

    border: 0;
    border-radius: 8px;

    background:
        rgba(255, 255, 255, 0.12);

    color: #ffffff;
    font-size: 25px;

    cursor: pointer;
}

/* =========================================================
   SIDEBAR USER
========================================================= */

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 11px;

    margin: 15px;
    padding: 13px;

    border-radius: 13px;

    background:
        rgba(255, 255, 255, 0.09);
}

.sidebar-avatar {
    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 42px;

    width: 42px;
    height: 42px;

    border:
        2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;

    background: #ffffff;
    color: var(--primary);

    font-size: 18px;
    font-weight: 800;
}

.hospital-sidebar .sidebar-avatar {
    color: var(--hospital-primary);
}

.sidebar-user-detail {
    min-width: 0;
}

.sidebar-user-detail strong {
    display: block;

    overflow: hidden;

    color: #ffffff;
    font-size: 13px;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-detail span {
    display: block;

    overflow: hidden;

    margin-top: 4px;

    color: #d9aeb9;
    font-size: 11px;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.hospital-sidebar .sidebar-user-detail span {
    color: #b8e1e3;
}

/* =========================================================
   SIDEBAR MENU
========================================================= */

.sidebar-menu {
    flex: 1;

    overflow-y: auto;

    padding: 4px 13px 20px;
}

.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background:
        rgba(255, 255, 255, 0.18);
}

.sidebar-menu-title {
    margin: 18px 10px 8px;

    color: #d9aeb9;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
}

.hospital-sidebar .sidebar-menu-title {
    color: #b8e1e3;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;

    min-height: 46px;
    margin-bottom: 5px;
    padding: 10px 13px;

    border-radius: 10px;

    color: #f9edf1;
    font-size: 14px;
    font-weight: 600;

    transition:
        background 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

.sidebar-link:hover {
    background:
        rgba(255, 255, 255, 0.10);

    color: #ffffff;

    transform: translateX(2px);
}

.sidebar-link.active {
    background: #ffffff;
    color: var(--primary);

    box-shadow:
        0 7px 18px rgba(0, 0, 0, 0.14);
}

.hospital-sidebar .sidebar-link.active {
    color: var(--hospital-primary);
}

.sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 25px;

    width: 25px;

    font-size: 18px;
}

.logout-link {
    margin-top: 10px;

    background:
        rgba(255, 85, 85, 0.13);

    color: #ffd8d8;
}

.logout-link:hover {
    background: #c93636;
}

/* =========================================================
   SIDEBAR FOOTER
========================================================= */

.sidebar-footer {
    padding: 14px 18px;

    border-top:
        1px solid rgba(255, 255, 255, 0.12);

    text-align: center;
}

.sidebar-footer span {
    display: block;

    overflow: hidden;

    color: #ffffff;
    font-size: 12px;
    font-weight: 700;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer small {
    display: block;

    margin-top: 4px;

    color: #d9aeb9;
    font-size: 10px;
}

.hospital-sidebar .sidebar-footer small {
    color: #b8e1e3;
}

/* =========================================================
   DASHBOARD MAIN
========================================================= */

.dashboard-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

/* =========================================================
   FIXED TOPBAR
========================================================= */

.dashboard-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 900;

    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: var(--topbar-height);
    padding: 10px 28px;

    border-bottom: 1px solid #dfe5ec;

    background:
        rgba(255, 255, 255, 0.97);

    box-shadow:
        0 3px 12px rgba(34, 50, 75, 0.07);

    backdrop-filter: blur(8px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-left strong {
    display: block;

    color: #283547;
    font-size: 18px;
}

.topbar-left span {
    display: block;

    margin-top: 3px;

    color: #7a8593;
    font-size: 12px;
}

.topbar-user {
    text-align: right;
}

.topbar-user-name {
    display: block;

    color: #2e3948;
    font-size: 13px;
    font-weight: 700;
}

.topbar-role {
    display: block;

    margin-top: 3px;

    color: #7b8693;
    font-size: 11px;
}

.sidebar-toggle {
    display: none;

    width: 42px;
    height: 42px;
    padding: 0;

    border: 1px solid #d8dee7;
    border-radius: 10px;

    background: #ffffff;
    color: var(--primary);

    font-size: 22px;

    cursor: pointer;
}

/* =========================================================
   DASHBOARD CONTENT
========================================================= */

.dashboard-content {
    padding:
        calc(var(--topbar-height) + 25px)
        28px
        30px;
}

.dashboard-welcome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    margin-bottom: 22px;
    padding: 24px 26px;

    border-radius: 17px;

    background:
        linear-gradient(
            135deg,
            #ffffff 0%,
            #f9edf1 100%
        );

    box-shadow: var(--shadow-light);
}

.hospital-sidebar
~ .sidebar-overlay
~ .dashboard-main
.dashboard-welcome {
    background:
        linear-gradient(
            135deg,
            #ffffff 0%,
            #e9f7f8 100%
        );
}

.dashboard-welcome h1 {
    margin: 0 0 7px;

    color: var(--primary);
    font-size: 25px;
}

.dashboard-welcome p {
    margin: 0;

    color: var(--text-muted);
    font-size: 14px;
}

.welcome-date {
    min-width: 145px;
    padding: 13px 16px;

    border-radius: 11px;

    background: #ffffff;

    text-align: center;

    box-shadow:
        0 5px 14px rgba(38, 50, 70, 0.07);
}

.welcome-date span {
    display: block;

    color: #7b8693;
    font-size: 11px;
}

.welcome-date strong {
    display: block;

    margin-top: 5px;

    color: var(--primary);
    font-size: 17px;
}

/* =========================================================
   STAT CARDS
========================================================= */

.stats-grid {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    gap: 18px;

    margin-bottom: 22px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;

    min-width: 0;
    padding: 21px;

    border-radius: 15px;

    background: #ffffff;

    box-shadow:
        0 8px 22px rgba(30, 48, 75, 0.09);
}

.stat-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 52px;

    width: 52px;
    height: 52px;

    border-radius: 14px;

    background: #f7e7ec;

    font-size: 26px;
}

.stat-card-content {
    min-width: 0;
}

.stat-card-content span,
.stat-card > span {
    display: block;

    overflow: hidden;

    color: #788391;
    font-size: 13px;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-card-content strong,
.stat-card > strong {
    display: block;

    margin-top: 7px;

    color: #273547;
    font-size: 28px;
}

/* =========================================================
   CONTENT CARDS
========================================================= */

.content-card {
    margin-bottom: 22px;
    padding: 23px;

    border-radius: 16px;

    background: #ffffff;

    box-shadow: var(--shadow-light);
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;

    margin-bottom: 18px;
}

.section-title h2 {
    margin: 0;

    color: #273547;
    font-size: 19px;
}

.section-title p {
    margin: 5px 0 0;

    color: #7a8593;
    font-size: 12px;
}

.section-title span {
    color: #7b8490;
    font-size: 13px;
}

/* =========================================================
   TABLES
========================================================= */

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;

    border-collapse: collapse;
}

th,
td {
    padding: 13px;

    border-bottom: 1px solid #e7ebf0;

    text-align: left;
    white-space: nowrap;
}

th {
    background: #f6f8fb;
    color: #354255;
    font-size: 13px;
}

td {
    color: #4e5b6b;
    font-size: 14px;
}

tbody tr:hover {
    background: #fafbfd;
}

.empty-table {
    padding: 35px !important;

    color: #7a8492;

    text-align: center;
}

/* =========================================================
   STATUS BADGES
========================================================= */

.status {
    display: inline-block;

    padding: 5px 9px;

    border-radius: 20px;

    font-size: 12px;
    font-weight: 700;
}

.status.active {
    background: #e0f6e7;
    color: #1e7739;
}

.status.inactive {
    background: #ffe6e6;
    color: #a52626;
}

.status.pending {
    background: #fff1d2;
    color: #8a6200;
}

/* =========================================================
   PROFILE
========================================================= */

.profile-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.profile-grid div {
    padding: 16px;

    border-radius: 10px;

    background: #f7f9fc;
}

.profile-grid span {
    display: block;

    margin-bottom: 6px;

    color: #727d89;
    font-size: 13px;
}

.profile-grid strong {
    color: #273547;
}

.profile-grid .full {
    grid-column: 1 / -1;
}

.empty-module {
    padding: 28px;

    border: 1px dashed #c6cfda;
    border-radius: 12px;

    background: #f7f9fc;

    color: #667085;
}

/* =========================================================
   INSTALL PAGE
========================================================= */

.install-body {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 100vh;
    padding: 30px;

    background: #edf1f6;
}

.install-card {
    width: min(650px, 100%);
    padding: 30px;
}

.install-card h1 {
    margin-top: 0;
}

.install-card h3 {
    margin-top: 26px;
    color: var(--primary);
}

/* =========================================================
   SIDEBAR OVERLAY
========================================================= */

.sidebar-overlay {
    display: none;

    position: fixed;
    inset: 0;
    z-index: 1050;

    background:
        rgba(16, 24, 38, 0.58);
}

.sidebar-overlay.overlay-show {
    display: block;
}

/* =========================================================
   RESPONSIVE - LARGE TABLET
========================================================= */

@media (max-width: 1150px) {

    .stats-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

/* =========================================================
   RESPONSIVE - TABLET
========================================================= */

@media (max-width: 900px) {

    .home-layout {
        grid-template-columns: 1fr;
    }

    .letters-scroll {
        height: 360px;
    }

    .fixed-sidebar {
        transform: translateX(-105%);

        transition:
            transform 0.24s ease;
    }

    .fixed-sidebar.sidebar-open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .dashboard-main {
        margin-left: 0;
    }

    .dashboard-topbar {
        left: 0;

        padding-right: 18px;
        padding-left: 18px;
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .dashboard-content {
        padding-right: 18px;
        padding-left: 18px;
    }

    body.sidebar-mobile-open {
        overflow: hidden;
    }
}

/* =========================================================
   RESPONSIVE - MOBILE
========================================================= */

@media (max-width: 650px) {

    .site-header h1 {
        font-size: 23px;
    }

    .home-layout {
        padding: 18px;
    }

    .dashboard-topbar {
        min-height: 66px;
    }

    .topbar-left strong {
        font-size: 15px;
    }

    .topbar-left span,
    .topbar-user {
        display: none;
    }

    .dashboard-content {
        padding-top: 88px;
    }

    .dashboard-welcome {
        align-items: flex-start;
        flex-direction: column;

        padding: 20px;
    }

    .dashboard-welcome h1 {
        font-size: 21px;
    }

    .welcome-date {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-title .btn {
        width: 100%;

        text-align: center;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }

    .profile-grid .full {
        grid-column: auto;
    }

    .topbar {
        align-items: flex-start;
        gap: 12px;
    }

    .dashboard-container {
        padding: 18px;
    }

    .letters-track {
        animation-duration: 30s;
    }

    .content-card {
        padding: 17px;
    }

    th,
    td {
        padding: 11px;
        font-size: 12px;
    }
}

/* =========================================================
   VERY SMALL MOBILE
========================================================= */

@media (max-width: 420px) {

    .fixed-sidebar {
        width: 88%;
        max-width: 300px;
    }

    .dashboard-topbar {
        padding-right: 12px;
        padding-left: 12px;
    }

    .dashboard-content {
        padding-right: 12px;
        padding-left: 12px;
    }

    .btn-danger {
        padding-right: 11px;
        padding-left: 11px;
        font-size: 12px;
    }

    .stat-card {
        padding: 17px;
    }

    .stat-card-icon {
        flex-basis: 46px;

        width: 46px;
        height: 46px;

        font-size: 22px;
    }

    .stat-card-content strong,
    .stat-card > strong {
        font-size: 24px;
    }
}

/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }

    .letters-track {
        animation: none;
    }

    .letters-scroll {
        overflow-y: auto;
    }
}