/* ============================================
   Hospitalink — Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #161625;
    --bg-card: rgba(26, 26, 46, 0.7);
    --bg-card-hover: rgba(30, 30, 55, 0.85);
    --bg-input: rgba(255, 255, 255, 0.04);
    --bg-input-focus: rgba(255, 255, 255, 0.08);

    --text-primary: #e8e8f0;
    --text-secondary: #8b8ba3;
    --text-muted: #5c5c78;
    --text-accent: #a78bfa;

    --accent-primary: #7c3aed;
    --accent-primary-light: #a78bfa;
    --accent-primary-dark: #5b21b6;
    --accent-secondary: #06b6d4;
    --accent-danger: #f43f5e;
    --accent-danger-light: #fb7185;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;

    --border-color: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(124, 58, 237, 0.3);
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(124, 58, 237, 0.15);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Animated background gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(124, 58, 237, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(124, 58, 237, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: bgPulse 15s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* --- Layout --- */
.app-wrapper {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

/* --- Header --- */
.app-header {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeInDown 0.6s ease-out;
}

.app-header .logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--border-radius-lg);
    font-size: 28px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.3);
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
}

/* --- Stats Bar --- */
.stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.stat-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 20px;
    text-align: center;
    backdrop-filter: blur(12px);
    transition: var(--transition-normal);
}

.stat-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary-light);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 4px;
    font-weight: 500;
}

.stat-card:nth-child(2) .stat-value {
    color: var(--accent-secondary);
}

/* --- Toolbar --- */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border: none;
    border-radius: var(--border-radius-md);
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after {
    opacity: 1;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-dark));
    color: white;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 24px rgba(124, 58, 237, 0.45);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
}

.btn-secondary:hover {
    border-color: var(--border-accent);
    background: var(--bg-card-hover);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-danger), #be123c);
    color: white;
    box-shadow: 0 4px 16px rgba(244, 63, 94, 0.25);
}

.btn-danger:hover {
    box-shadow: 0 6px 24px rgba(244, 63, 94, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.btn-danger-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 6px 10px;
    font-size: 0.8rem;
    border-radius: var(--border-radius-sm);
}

.btn-danger-ghost:hover {
    color: var(--accent-danger);
    background: rgba(244, 63, 94, 0.1);
}

.btn-add-lit {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent-secondary);
    border: 1px dashed rgba(6, 182, 212, 0.3);
    padding: 10px 18px;
    font-size: 0.8rem;
    border-radius: var(--border-radius-sm);
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.btn-add-lit:hover {
    background: rgba(6, 182, 212, 0.18);
    border-color: rgba(6, 182, 212, 0.5);
}

.btn-icon {
    font-size: 1rem;
    display: inline-flex;
}

/* --- Room List --- */
.room-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: fadeInUp 0.6s ease-out 0.3s both;
}

.room-list-empty {
    text-align: center;
    padding: 80px 40px;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius-lg);
    color: var(--text-muted);
}

.room-list-empty .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.room-list-empty h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.room-list-empty p {
    font-size: 0.85rem;
}

/* --- Room Card --- */
.room-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    backdrop-filter: blur(12px);
    transition: var(--transition-normal);
    animation: slideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.room-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-sm);
}

.room-card.expanded {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
}

.room-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.room-header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.room-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-normal);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.room-toggle:hover {
    background: var(--bg-input-focus);
    color: var(--accent-primary-light);
}

.room-toggle.expanded {
    background: rgba(124, 58, 237, 0.15);
    color: var(--accent-primary-light);
    transform: rotate(90deg);
}

.room-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(124, 58, 237, 0.05));
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    flex-shrink: 0;
}

.room-name-input {
    flex: 1;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    padding: 8px 12px;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: var(--transition-normal);
    min-width: 0;
}

.room-name-input:hover {
    background: var(--bg-input);
    border-color: var(--border-color);
}

.room-name-input:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.room-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.room-bed-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
    white-space: nowrap;
}

/* --- Bed Container --- */
.room-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.room-body.expanded {
    max-height: 2000px;
}

.room-body-inner {
    padding: 0 20px 16px 20px;
    border-top: 1px solid var(--border-color);
}

/* --- Bed Item --- */
.bed-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.bed-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: var(--border-radius-sm);
    border: 1px solid transparent;
    transition: var(--transition-normal);
    animation: bedSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 16px;
}

@keyframes bedSlideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.bed-item:hover {
    border-color: var(--border-color);
    background: var(--bg-input-focus);
}

.bed-connector {
    width: 16px;
    height: 1px;
    background: var(--border-color);
    flex-shrink: 0;
    margin-left: -26px;
}

.bed-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
    opacity: 0.6;
}

.bed-name-input {
    flex: 1;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 5px 10px;
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition-normal);
    min-width: 0;
}

.bed-name-input:hover {
    background: rgba(255,255,255,0.03);
    border-color: var(--border-color);
}

.bed-name-input:focus {
    outline: none;
    background: rgba(255,255,255,0.05);
    border-color: var(--accent-secondary);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

/* --- Notifications / Toast --- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.35s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(12px);
}

.toast.success {
    background: rgba(16, 185, 129, 0.9);
}

.toast.error {
    background: rgba(244, 63, 94, 0.9);
}

.toast.info {
    background: rgba(124, 58, 237, 0.9);
}

.toast-exit {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(40px) scale(0.95);
    }
}

/* --- Loading State --- */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Animations --- */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Confirm Dialog --- */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.confirm-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: dialogIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dialogIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.confirm-dialog h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.confirm-dialog p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-confirm-cancel {
    padding: 10px 20px;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.btn-confirm-cancel:hover {
    background: var(--bg-input-focus);
    color: var(--text-primary);
}

.btn-confirm-delete {
    padding: 10px 20px;
    background: var(--accent-danger);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.btn-confirm-delete:hover {
    background: var(--accent-danger-light);
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .app-wrapper {
        padding: 24px 16px 60px;
    }

    .app-header h1 {
        font-size: 1.5rem;
    }

    .stats-bar {
        gap: 8px;
    }

    .stat-card {
        padding: 14px 10px;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .toolbar {
        flex-wrap: wrap;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.8rem;
    }

    .room-header {
        padding: 12px 14px;
        gap: 8px;
    }

    .room-body-inner {
        padding: 0 14px 12px;
    }

    .bed-item {
        margin-left: 8px;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Selection --- */
::selection {
    background: rgba(124, 58, 237, 0.3);
    color: white;
}
