/* ============================================
   FAMILY MILESTONES - STYLES
   Mobile-first responsive design
   Light & Dark theme support
   ============================================ */

:root {
    /* Light theme colors */
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-primary-light: #818cf8;
    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    
    --transition: all 0.2s ease;
}

[data-theme="dark"] {
    --color-primary: #818cf8;
    --color-primary-dark: #6366f1;
    --color-primary-light: #a5b4fc;
    
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --border-color: #374151;
}

/* ============================================
   GLOBAL STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color var(--transition), color var(--transition);
    overflow: hidden;
}

#root {
    width: 100%;
    height: 100%;
    display: flex;
}

/* ============================================
   SCREENS
   ============================================ */

.screen {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.auth-screen {
    display: flex !important;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.auth-container {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.auth-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.auth-container h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.restricted-message {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.app-screen {
    display: none !important;
    flex-direction: column;
    max-height: 100vh;
    overflow: hidden;
}

.app-screen.active,
.app-screen[style*="display: flex"] {
    display: flex !important;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */

.app-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.app-title {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

.install-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--color-primary);
    color: white;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    border-radius: var(--radius-md);
    gap: 1rem;
    font-size: 0.875rem;
}

.install-banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 1rem;
}

.ios-install-hint {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    background-color: var(--color-warning);
    color: white;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    border-radius: var(--radius-md);
    gap: 0.5rem;
    font-size: 0.875rem;
}

.btn-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-menu {
    display: none !important;
    flex-direction: column;
    position: absolute;
    top: 100%;
    right: 1rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-top: 0.5rem;
    min-width: 250px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.user-photo {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-email {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.tab-nav {
    display: flex;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.app-screen > div:nth-child(n+3) {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 5rem;
}

.tab-content {
    display: none;
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.tab-content.active {
    display: block;
}

.bottom-padding {
    height: 1rem;
}

/* ============================================
   NEXT EVENT BANNER
   ============================================ */

.next-event-banner {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.next-event-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.next-event-title {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.countdown-display {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.next-event-category {
    display: inline-block;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    backdrop-filter: blur(10px);
}

/* ============================================
   MILESTONE CARDS
   ============================================ */

.milestones-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0;
}

@media (min-width: 768px) {
    .milestones-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .milestones-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.milestone-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.milestone-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.milestone-photo {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.card-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.card-header h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    flex: 1;
    margin: 0;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.card-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.countdown {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary);
    letter-spacing: 0.05em;
}

.memory-badge {
    display: inline-block;
    background-color: var(--color-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.card-note {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

/* ============================================
   SAVINGS TRACKER
   ============================================ */

.savings-tracker {
    background-color: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.savings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.savings-amount {
    color: var(--text-secondary);
    font-weight: 600;
}

.progress-bar {
    height: 6px;
    background-color: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    transition: width 0.3s ease;
}

.savings-percentage {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
}

.add-savings-btn {
    margin-top: 0.25rem;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-primary-dark);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border-color);
}

.btn-danger {
    background-color: var(--color-danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-icon {
    padding: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.25rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ============================================
   FAB (Floating Action Button)
   ============================================ */

.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.fab:hover:not(:disabled) {
    transform: scale(1.1);
}

.fab:active:not(:disabled) {
    transform: scale(0.95);
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    align-items: flex-end;
    justify-content: center;
}

.modal[style*="display: flex"] {
    display: flex !important;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background-color: var(--bg-primary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 1.5rem;
    max-width: 100%;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

@media (min-width: 640px) {
    .modal-content {
        max-width: 500px;
        border-radius: var(--radius-xl);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
}

/* ============================================
   FORMS
   ============================================ */

.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group input:disabled,
.form-group textarea:disabled,
.form-group select:disabled {
    background-color: var(--bg-tertiary);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.input-with-addon {
    display: flex;
    gap: 0.5rem;
}

.input-with-addon input {
    flex: 1;
}

.input-with-addon select,
.addon {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
}

.addon {
    border: none;
    display: flex;
    align-items: center;
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
    cursor: pointer;
}

.form-group label input[type="checkbox"] {
    display: inline;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.form-actions .btn {
    flex: 1;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 640px) {
    .tab-nav {
        position: sticky;
        top: 0;
        z-index: 90;
    }

    .milestone-card {
        margin: 0;
    }

    .fab {
        bottom: 1rem;
        right: 1rem;
        width: 3rem;
        height: 3rem;
        font-size: 1.25rem;
    }

    .user-menu {
        min-width: 200px;
        right: 0;
    }

    .modal {
        align-items: stretch;
    }

    .modal-content {
        border-radius: 0;
        max-height: 100vh;
    }
}

@media (max-height: 600px) {
    .app-header {
        padding: 0.75rem;
    }

    .milestone-card {
        margin-bottom: 0;
    }

    .next-event-banner {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .countdown-display {
        font-size: 1.25rem;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.milestone-card {
    animation: fadeIn 0.3s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
