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

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-bg: #eef2ff;
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --bg: #f1f5f9;
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    --card: #ffffff;
    --card-hover: #fafafa;
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-gradient);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
    background: var(--card);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.baby-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.baby-selector select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.baby-selector select:hover {
    border-color: var(--primary-light);
}

.btn-icon {
    background: var(--bg);
    border: none;
    font-size: 1.35rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--primary-bg);
    transform: scale(1.05);
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    flex: 1;
    padding: 0.9rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab:hover:not(.active) {
    color: var(--text-secondary);
    background: var(--bg);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 1.25rem;
    animation: fadeIn 0.25s ease;
}

.tab-content.active {
    display: block;
}

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

/* Stats Cards */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card);
    padding: 1.25rem 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-light);
}

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

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.25rem;
    font-weight: 600;
}

/* Section Headers */
.recent-days h3, .quick-correlations h3, .form-section h3 {
    font-size: 0.8rem;
    margin-bottom: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

/* Days Grid */
.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.day-cell {
    background: var(--card);
    padding: 0.85rem 0.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-light);
}

.day-cell:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: var(--primary-light);
}

.day-cell.empty {
    background: transparent;
    box-shadow: none;
    border: 1px dashed var(--border);
}

.day-cell.empty:hover {
    background: var(--bg);
    border-color: var(--primary-light);
}

.day-cell .day-name {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.day-cell .day-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 0.15rem;
}

.day-cell .day-value.good {
    color: var(--success);
}

.day-cell .day-value.bad {
    color: var(--danger);
}

/* Correlations */
.correlation-item {
    background: var(--card);
    padding: 1rem 1.15rem;
    border-radius: var(--radius);
    margin-bottom: 0.7rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-light);
    transition: all 0.2s;
}

.correlation-item:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-light);
}

.correlation-factor {
    font-weight: 600;
    color: var(--text);
}

.correlation-impact {
    font-weight: 700;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}

.correlation-impact.positive {
    background: var(--success-bg);
    color: var(--success);
}

.correlation-impact.negative {
    background: var(--danger-bg);
    color: var(--danger);
}

.correlation-impact.neutral {
    background: var(--bg);
    color: var(--text-muted);
}

.correlation-confidence {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* Calendar */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    background: var(--card);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.calendar-header button {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.calendar-header button:hover {
    background: var(--primary-bg);
    border-color: var(--primary-light);
    color: var(--primary);
}

.calendar-header span {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.calendar-day-header {
    background: var(--text-secondary);
    padding: 0.6rem;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar-day {
    background: var(--card);
    min-height: 65px;
    padding: 0.35rem;
    cursor: pointer;
    position: relative;
    transition: all 0.15s;
}

.calendar-day:hover {
    background: var(--card-hover);
}

.calendar-day.other-month {
    opacity: 0.35;
}

.calendar-day.today {
    background: var(--primary-bg);
}

.calendar-day .day-number {
    font-size: 0.85rem;
    font-weight: 600;
}

.calendar-day.today .day-number {
    color: var(--primary);
    font-weight: 700;
}

.calendar-day .day-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.calendar-day .day-indicator.tracked {
    background: var(--primary);
}

.calendar-day .day-indicator.good {
    background: var(--success);
}

.calendar-day .day-indicator.bad {
    background: var(--danger);
}

/* Entry Form */
.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    background: var(--card);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.entry-header button {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.entry-header button:hover {
    background: var(--primary-bg);
    border-color: var(--primary-light);
    color: var(--primary);
}

.entry-header span {
    font-weight: 700;
    font-size: 1.05rem;
}

.entry-form {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}

.form-section {
    margin-bottom: 1.75rem;
}

.field-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border-light);
}

.field-row:last-child {
    border-bottom: none;
}

.field-label {
    font-weight: 500;
    color: var(--text);
}

/* Boolean Toggle */
.toggle-group {
    display: flex;
    gap: 0.4rem;
}

.toggle-btn {
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.toggle-btn:hover {
    border-color: var(--primary-light);
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

/* Number Input */
.field-input {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 85px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
}

.field-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

/* Scale Slider */
.scale-group {
    display: flex;
    gap: 0.3rem;
}

.scale-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.scale-btn:hover {
    border-color: var(--primary-light);
}

.scale-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

/* Time Input */
.time-input {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.time-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

/* Notes */
textarea {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 85px;
    transition: all 0.2s;
    background: var(--bg);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-bg);
    background: white;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.75rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none;
}

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

.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

.btn-close {
    background: var(--bg);
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.modal-tab {
    flex: 1;
    padding: 0.85rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 600;
    transition: all 0.2s;
}

.modal-tab:hover {
    background: var(--bg);
}

.modal-tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.settings-content {
    display: none;
    padding: 1.25rem;
}

.settings-content.active {
    display: block;
}

/* Field List */
.field-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    border: 1px solid var(--border-light);
    transition: all 0.2s;
}

.field-item:hover {
    border-color: var(--primary-light);
}

.field-item-info {
    display: flex;
    flex-direction: column;
}

.field-item-name {
    font-weight: 600;
    color: var(--text);
}

.field-item-type {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.field-item-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-small {
    padding: 0.3rem 0.6rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-delete {
    background: var(--danger-bg);
    color: var(--danger);
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
}

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

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

/* Correlation Controls */
.correlation-controls {
    background: var(--card);
    padding: 1.15rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.correlation-controls label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.correlation-controls select {
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    font-weight: 500;
    cursor: pointer;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.empty-state p {
    font-size: 0.95rem;
}

/* Add Field Form */
#addFieldForm {
    padding: 1.25rem;
}

#addFieldForm input,
#addFieldForm select {
    width: 100%;
    padding: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
}

#addFieldForm input:focus,
#addFieldForm select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

#addFieldForm label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

#fieldConfig {
    margin-bottom: 1rem;
}

.select-options-input {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.select-options-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* Upgrade Modal */
.modal-upgrade {
    max-width: 380px;
}

.upgrade-content {
    padding: 1.25rem;
    text-align: center;
}

.upgrade-feature {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.upgrade-benefits {
    text-align: left;
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}

.upgrade-benefits h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.upgrade-benefits ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.upgrade-benefits li {
    padding: 0.35rem 0;
    font-size: 0.9rem;
    color: var(--text);
}

.upgrade-price {
    margin-bottom: 1.25rem;
}

.upgrade-price .price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    display: block;
}

.upgrade-price .price-note {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.upgrade-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.btn-upgrade {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
}

.btn-upgrade:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(245, 158, 11, 0.4);
}

.demo-unlock {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.demo-unlock a {
    color: var(--primary);
    text-decoration: none;
}

.demo-unlock a:hover {
    text-decoration: underline;
}

/* Premium indicator */
.premium-locked {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    color: var(--warning);
    background: var(--warning-bg);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}

/* Demo Badge */
.demo-badge {
    background: linear-gradient(135deg, var(--warning) 0%, #f97316 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Responsive */
@media (max-width: 600px) {
    .stats-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    .days-grid {
        gap: 0.4rem;
    }
    
    .day-cell {
        padding: 0.6rem 0.3rem;
    }
    
    .day-cell .day-value {
        font-size: 1.15rem;
    }
    
    .tab-content {
        padding: 1rem;
    }
    
    .correlation-item {
        padding: 0.85rem;
    }
}
