/* =============================================================================
   SaaS Template - Base Styles
   ============================================================================= */

:root {
    /* Colors */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;

    /* Neutrals */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    --border-radius: 8px;
    --box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --box-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--gray-800);
    background-color: var(--gray-50);
}

/* =============================================================================
   Container & Layout
   ============================================================================= */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* =============================================================================
   Typography
   ============================================================================= */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--gray-900);
}

h1 { font-size: 2.5rem; margin-bottom: 1rem; }
h2 { font-size: 2rem; margin-bottom: 0.875rem; }
h3 { font-size: 1.5rem; margin-bottom: 0.75rem; }

.subtitle {
    font-size: 1.25rem;
    color: var(--gray-600);
    margin-bottom: 2rem;
}

/* =============================================================================
   Buttons
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--gray-200);
    color: var(--gray-800);
}

.btn-secondary:hover {
    background-color: var(--gray-300);
}

.btn-google {
    background-color: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-google:hover {
    background-color: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-block {
    width: 100%;
}

.google-icon {
    width: 20px;
    height: 20px;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* =============================================================================
   Forms
   ============================================================================= */

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-result {
    margin-top: 1rem;
}

/* =============================================================================
   Alerts
   ============================================================================= */

.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* =============================================================================
   Landing Page
   ============================================================================= */

.hero {
    text-align: center;
    padding: 3rem 0;
    border-bottom: 1px solid var(--gray-200);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.feature-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.feature-card h3 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.cta {
    text-align: center;
    padding: 3rem 0;
}

.architecture {
    margin: 3rem 0;
}

.arch-diagram {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.arch-component {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    text-align: center;
}

.arch-component strong {
    display: block;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 1px solid var(--gray-200);
    color: var(--gray-600);
}

/* =============================================================================
   Login Page
   ============================================================================= */

.login-container {
    max-width: 420px;
    margin: 4rem auto;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-main {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
}

.login-form {
    margin-bottom: 1.5rem;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--gray-600);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--gray-300);
}

.divider span {
    padding: 0 1rem;
}

.oauth-section {
    margin: 1.5rem 0;
}

.demo-credentials {
    margin-top: 2rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-200);
}

.demo-credentials h3 {
    font-size: 0.875rem;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

.credential-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.credential-item {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.credential-item code {
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
}

.login-footer a {
    color: var(--primary);
    text-decoration: none;
}

/* =============================================================================
   Dashboard Layout
   ============================================================================= */

.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    padding: 1.5rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 0 1.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--gray-700);
    padding-bottom: 1rem;
}

.sidebar-header h2 {
    color: white;
    font-size: 1.25rem;
}

.user-role {
    font-size: 0.875rem;
    color: var(--gray-300);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--gray-300);
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.75rem;
}

.nav-item:hover {
    background: var(--gray-800);
    color: white;
}

.nav-item.active {
    background: var(--gray-800);
    color: white;
    border-left: 3px solid var(--primary);
}

.nav-icon {
    font-size: 1.25rem;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
}

.content-header {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 1rem;
}

.user-email {
    color: var(--gray-600);
    font-size: 0.875rem;
}

/* =============================================================================
   Dashboard Components
   ============================================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.recent-patients {
    margin-top: 2rem;
}

/* =============================================================================
   Patients Page
   ============================================================================= */

.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.filters input[type="search"] {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
}

.patients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.patient-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    cursor: pointer;
    transition: all 0.2s;
}

.patient-card:hover {
    box-shadow: var(--box-shadow-lg);
    transform: translateY(-2px);
}

.patient-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.patient-status {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.patient-status.active {
    background: #d1fae5;
    color: #065f46;
}

.patient-info p {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* =============================================================================
   Modal
   ============================================================================= */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-600);
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* =============================================================================
   Loading States
   ============================================================================= */

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--gray-600);
}

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

.spinner.large {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

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

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

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

    .feature-grid,
    .arch-diagram,
    .stats-grid,
    .patients-grid {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .filters {
        flex-direction: column;
    }
}
