/* 
   SmartParchi Master Design System (v2.0)
   Principles: Premium, Minimalistic, Responsive, Mobile-First
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap');

:root {
    color-scheme: light;
    /* Core Palette: Teal & Mint */
    --primary: #0d9488;
    --primary-soft: rgba(13, 148, 136, 0.1);
    --primary-glow: rgba(13, 148, 136, 0.25);
    --secondary: #6366f1;
    --secondary-soft: rgba(99, 102, 241, 0.12);
    /* Indigo for contrast */
    --accent: #2dd4bf;

    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Layout & Surface */
    --bg-body: #f8fafc;
    --bg-main: #ffffff;
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-soft: #e2e8f0;

    /* Effects */
    --radius-sm: 0.75rem;
    --radius-md: 1.25rem;
    --radius-lg: 2.25rem;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-glow: 0 10px 30px -5px rgba(13, 148, 136, 0.25);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* Responsive Breakpoints Utility */
    --mobile: 480px;
    --tablet: 768px;
    --desktop: 1024px;

    /* Typography */
    --font-primary: 'Plus Jakarta Sans', sans-serif;
    --font-display: 'Outfit', sans-serif;
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --bg-body: #020617;
    --bg-main: #0f172a;
    --surface: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-soft: #1e293b;
    --primary-soft: rgba(20, 184, 166, 0.15);
    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.4);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

/* Production Safeguards */
img,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
    hyphens: none;
}

body {
    background-color: var(--bg-body, #f8fafc);
    color: var(--text-main, #0f172a);
    font-family: var(--font-primary, sans-serif);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: var(--transition);
}

h1,
h2,
h3,
h4,
h5,
.font-display {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

/* --- Layout Components --- */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 5vw, 2.5rem);
    width: 100%;
    /* Ensure no overflow */
}

.sp-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.sp-flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Premium Surface --- */

.sp-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-soft);
    padding: clamp(1.25rem, 6vw, 2rem);
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.sp-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.sp-glass {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
}

[data-theme="dark"] .sp-glass {
    background: rgba(15, 23, 42, 0.6);
}

/* --- Buttons --- */

.sp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    padding: 1rem 2.25rem;
    border-radius: 1.25rem;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    text-decoration: none;
    outline: none;
    white-space: nowrap;
    font-family: var(--font-primary);
    min-height: 56px;
}

.sp-btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 10px 25px -5px rgba(13, 148, 136, 0.4);
}

.sp-btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px -5px rgba(13, 148, 136, 0.5);
    filter: brightness(1.1);
}

.sp-btn-outline {
    background: white;
    border: 2px solid var(--border-soft);
    color: var(--text-main);
}

.sp-btn-outline:hover {
    background: var(--bg-main);
    border-color: var(--text-muted);
    transform: translateY(-2px);
}

.sp-btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
}

/* --- Forms & Inputs --- */

.sp-input-group {
    margin-bottom: 1.5rem;
    width: 100%;
}

.sp-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.sp-input {
    width: 100%;
    padding: 1.15rem 1rem;
    border-radius: 1.15rem;
    border: 2px solid var(--border-soft);
    background: var(--bg-main);
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.sp-input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 5px var(--primary-soft);
    outline: none;
}

select.sp-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24' fill='%2364748b'%3E%3Cpath d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.25rem center;
    background-size: 1.25rem;
    padding-right: 3rem;
    cursor: pointer;
}

/* --- Status & Badges --- */

.sp-badge {
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.7rem;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.sp-badge-online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1.5px solid rgba(16, 185, 129, 0.2);
}

.sp-badge-offline {
    background: rgba(244, 63, 94, 0.1);
    color: var(--error);
    border: 1.5px solid rgba(244, 63, 94, 0.2);
}

/* --- Navigation & Menu --- */

.sp-app-nav {
    position: sticky;
    top: 1rem;
    margin: 1rem auto;
    width: calc(100% - 2rem);
    max-width: 1100px;
    z-index: 1000;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- Charts & Data --- */

.sp-chart-container {
    height: 350px;
    width: 100%;
}

.sp-patient-list-container {
    overflow-y: auto;
    padding-right: 0.5rem;
    max-height: 720px;
    /* Precise height for 10 items in dashboard */
    transition: max-height 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--border-soft) transparent;
}

@media (max-width: 768px) {
    .sp-patient-list-container {
        max-height: 360px;
        /* Precise height for 5 items in mobile */
    }
}

/* --- Responsive Adaptations --- */

/* Tablet & Mobile Adjustments */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .sp-app-nav {
        top: 0;
        margin: 0;
        width: 100%;
        border-radius: 0;
        padding: 0.75rem 1rem;
    }

    .sp-card {
        padding: 1.5rem;
    }

    h1 {
        font-size: 2.25rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.85rem;
    }

    .sp-btn {
        width: 100%;
    }
}

/* Legacy Support & Utilities */
.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--primary);
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.animate-fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Custom Scrollbar for Premium Feel */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-soft);
    border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Mobile App Interactions */
.sp-btn:active {
    transform: scale(0.96);
    opacity: 0.9;
}

/* .sp-card:active { transform: scale(0.98); } Removed to prevent form jitter */

/* Prevent text selection on buttons for app-like feel */
.sp-btn,
.nav-link,
.nav-brand {
    user-select: none;
    -webkit-user-select: none;
}

/* Smooth Navigation Transitions */
body {
    animation: pageTransition 0.4s ease-out;
}

@keyframes pageTransition {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Floating Action Button (Utility) */
.sp-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 15px 35px var(--primary-glow);
    z-index: 1000;
    cursor: pointer;
    transition: var(--transition);
}

.sp-fab:hover {
    transform: translateY(-5px) rotate(90deg);
}

@media (max-width: 768px) {
    .sp-fab {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 56px;
        height: 56px;
    }
}

/* --- Interactive Utilities --- */

.sp-loader {
    width: 64px;
    height: 64px;
    border: 5px solid var(--primary-soft);
    border-bottom-color: var(--primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: sp-rotation 1s linear infinite;
}

@keyframes sp-rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}