/* ============================================
   Health Companion - Global Styles
   Single source of truth for all pages
   ============================================ */

/* CSS Variables - Green Theme */
:root {
    /* Primary Colors */
    --primary: #10b981;
    --primary-light: #34d399;
    --primary-lighter: #6ee7b7;
    --primary-dark: #059669;

    /* Secondary Colors */
    --secondary: #06b6d4;
    --secondary-light: #22d3ee;

    /* Background */
    --bg-gradient-start: #6ee7b7;
    --bg-gradient-end: #34d399;
    --bg-dark: #0f172a;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-dark: rgba(30, 41, 59, 0.7);

    /* Text */
    --text-dark: #1a202c;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-white: #f1f5f9;

    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Borders */
    --border-light: rgba(255, 255, 255, 0.3);
    --border-dark: rgba(255, 255, 255, 0.1);

    /* Shadows */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 40px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 15px 50px rgba(0, 0, 0, 0.25);
    --shadow-primary: 0 8px 25px rgba(16, 185, 129, 0.4);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base Body - Light Theme (Green Gradient) */
body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    color: var(--text-dark);
}

/* Dark Theme Body */
body.dark-theme {
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 40%);
    color: var(--text-white);
}

/* Animated Background Overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(110, 231, 183, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(52, 211, 153, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(16, 185, 129, 0.2) 0%, transparent 50%);
    animation: gradientShift 15s ease infinite;
    pointer-events: none;
    z-index: -1;
}

body.dark-theme::before {
    display: none;
}

@keyframes gradientShift {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

/* ============================================
   Header / Navigation
   ============================================ */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 15px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header.dark {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-dark);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    text-decoration: none;
}

.logo-icon {
    font-size: 1.5rem;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-block;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    cursor: pointer;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(16, 185, 129, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--primary);
    color: var(--primary);
    box-shadow: none;
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

.btn-disabled {
    background: #cbd5e1;
    color: #64748b;
    box-shadow: none;
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.7;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card:hover::before {
    transform: scaleX(1);
}

.card h3 {
    color: var(--text-dark);
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 700;
}

.card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 15px;
}

/* Dark Card */
.card.dark {
    background: var(--bg-card-dark);
    border: 1px solid var(--border-dark);
}

.card.dark h3 {
    color: var(--text-white);
}

.card.dark p {
    color: var(--text-light);
}

/* ============================================
   Container & Layout
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
    z-index: 1;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.page-subtitle {
    color: var(--text-muted);
    margin-bottom: 30px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

/* ============================================
   Front Page Specifics (Hero & Grid)
   ============================================ */
.hero-section {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 30px;
    margin-bottom: 40px;
    align-items: center;
}

.hero-status {
    padding-right: 20px;
}

.hero-actions {
    background: white;
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    border: 1px solid var(--border-light);
}

.hero-welcome {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-dark);
    /* Changed from white for better contrast if bg is light, but bg is gradient */
    margin-bottom: 10px;
    /* If background is gradient, white text is better. Let's stick to .welcome h1 style but adjust */
    color: white;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.hero-subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 25px;
}

.grid-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.feature-card {
    background: white;
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    /* As per spec */
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    /* Make whole card clickable */
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 15px;
    background: rgba(16, 185, 129, 0.1);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--primary);
}

.feature-title {
    font-size: 1.1rem;
    /* 16-17px approx */
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 8px;
}

.feature-desc {
    font-size: 0.9rem;
    /* 14-15px */
    color: #64748b;
    margin-bottom: 20px;
    flex-grow: 1;
}

.feature-cta {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.feature-cta::after {
    content: '→';
    transition: transform 0.2s;
}

.feature-card:hover .feature-cta::after {
    transform: translateX(5px);
}

/* Specific button for Hero CTA */
.btn-hero-primary {
    display: block;
    width: 100%;
    padding: 18px 30px;
    font-size: 1.1rem;
    border-radius: var(--radius-md);
    background: var(--primary);
    /* Green */
    color: white;
    font-weight: 700;
    margin-bottom: 15px;
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
}

.btn-hero-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(16, 185, 129, 0.6);
}

.btn-hero-secondary {
    display: block;
    width: 100%;
    padding: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: none;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    transition: all 0.2s;
}

.btn-hero-secondary:hover {
    background: #f8fafc;
    color: var(--primary);
    border-color: var(--primary);
}

@media (max-width: 900px) {
    .hero-section {
        grid-template-columns: 1fr;
    }

    .grid-features {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .grid-features {
        grid-template-columns: 1fr;
    }

    .hero-actions {
        position: sticky;
        bottom: 20px;
        z-index: 90;
    }
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 2px solid #e2e8f0;
    background: white;
    color: var(--text-dark);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Dark Form */
.dark-theme .form-group label {
    color: var(--text-white);
}

.dark-theme .form-input,
.dark-theme .form-select,
.dark-theme .form-textarea {
    background: rgba(0, 0, 0, 0.3);
    border-color: var(--border-dark);
    color: var(--text-white);
}

/* ============================================
   Badges & Status
   ============================================ */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--primary);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: #92400e;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: #991b1b;
}

/* ============================================
   Links
   ============================================ */
.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--text-dark);
}

.dark-theme .back-link:hover {
    color: white;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mt-4 {
    margin-top: 2rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.gap-3 {
    gap: 1.5rem;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s ease-out;
}

/* ============================================
   Responsive - Comprehensive Breakpoints
   ============================================ */

/* Large Tablets & Small Desktops (992px - 1199px) */
@media (max-width: 1199px) {
    .container {
        max-width: 960px;
    }

    .hero-section {
        gap: 20px;
    }
}

/* Tablets (768px - 991px) */
@media (max-width: 991px) {
    .header {
        padding: 12px 25px;
    }

    .container {
        max-width: 720px;
        padding: 30px 20px;
    }

    .hero-section {
        grid-template-columns: 1fr;
    }

    .hero-status {
        padding-right: 0;
        text-align: center;
    }

    .hero-welcome {
        font-size: 2rem;
    }

    .grid-features {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-title {
        font-size: 1.75rem;
    }

    .card {
        padding: 20px;
    }
}

/* Small Tablets & Large Phones (576px - 767px) */
@media (max-width: 767px) {
    .header {
        padding: 12px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .logo {
        font-size: 1.1rem;
    }

    .logo-icon {
        font-size: 1.3rem;
    }

    .btn-logout {
        padding: 8px 15px;
        font-size: 0.85rem;
    }

    .container {
        padding: 20px 15px;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .page-subtitle {
        font-size: 0.95rem;
    }

    .hero-welcome {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .hero-actions {
        padding: 20px;
    }

    .grid-features {
        grid-template-columns: 1fr;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .feature-card {
        padding: 20px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.8rem;
    }

    .btn-hero-primary {
        padding: 15px 25px;
        font-size: 1rem;
    }

    .card {
        padding: 18px;
        border-radius: var(--radius-md);
    }

    .card h3 {
        font-size: 1rem;
    }

    .form-input,
    .form-select,
    .form-textarea {
        padding: 10px 14px;
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }
}

/* Mobile Phones (up to 575px) */
@media (max-width: 575px) {
    body {
        font-size: 14px;
    }

    .header {
        padding: 10px 12px;
    }

    .logo span:not(.logo-icon) {
        font-size: 0.95rem;
    }

    .container {
        padding: 15px 12px;
    }

    .page-title {
        font-size: 1.3rem;
    }

    .page-subtitle {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }

    .hero-welcome {
        font-size: 1.5rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: 15px;
    }

    .hero-actions {
        padding: 15px;
        margin: 0 -12px;
        border-radius: 0;
        position: sticky;
        bottom: 0;
        z-index: 90;
    }

    .feature-icon {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }

    .feature-title {
        font-size: 1rem;
    }

    .feature-desc {
        font-size: 0.85rem;
    }

    .btn {
        width: 100%;
        text-align: center;
    }

    .btn-hero-primary {
        padding: 14px 20px;
        font-size: 0.95rem;
    }

    .card {
        padding: 15px;
    }

    .badge {
        padding: 3px 10px;
        font-size: 0.75rem;
    }

    .alert {
        padding: 12px 15px;
        font-size: 0.9rem;
    }

    .toast {
        left: 15px;
        right: 15px;
        bottom: 15px;
        text-align: center;
    }

    /* Stack form elements fully */
    .form-group {
        margin-bottom: 15px;
    }

    .form-group label {
        font-size: 0.9rem;
    }
}

/* Extra Small Phones (up to 375px) */
@media (max-width: 375px) {
    .header {
        padding: 8px 10px;
    }

    .logo-icon {
        font-size: 1.2rem;
    }

    .logo span:not(.logo-icon) {
        font-size: 0.85rem;
    }

    .btn-logout {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .page-title {
        font-size: 1.2rem;
    }

    .hero-welcome {
        font-size: 1.3rem;
    }

    .container {
        padding: 12px 10px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        padding: 12px 24px;
    }

    .feature-card:hover {
        transform: none;
    }

    .card:hover {
        transform: none;
    }

    .card::before {
        transform: scaleX(1);
    }

    /* Larger tap targets */
    .category-pill,
    .badge {
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }

    /* Remove hover-only animations */
    .feature-card:hover .feature-cta::after {
        transform: none;
    }
}

/* Landscape Mode for Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 8px 20px;
    }

    .hero-section {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }

    .hero-actions {
        position: static;
    }

    .container {
        padding: 15px 20px;
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .card {
        border-width: 0.5px;
    }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    body::before {
        animation: none;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }

    body::before {
        display: none;
    }

    .header,
    .btn,
    .toast {
        display: none;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 500;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
    max-width: calc(100vw - 40px);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.warning {
    background: var(--warning);
}

/* ============================================
   Loading Spinner
   ============================================ */
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.dark-theme .spinner {
    border-color: var(--border-dark);
    border-top-color: var(--primary);
}

/* ============================================
   Additional Responsive Utilities
   ============================================ */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }
}

/* Fluid Typography */
.fluid-heading {
    font-size: clamp(1.25rem, 4vw, 2rem);
}

.fluid-text {
    font-size: clamp(0.875rem, 2vw, 1rem);
}