/* CSS Variables */
:root {
    --primary-color: #00b4d8;
    --primary-dark: #0096c7;
    --primary-light: #90e0ef;
    --secondary-color: #48cae4;
    --accent-color: #023e8a;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --bg-color: #f0f9ff;
    --card-bg: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a68;
    --text-light: #8888a0;
    --border-color: #e0e8f0;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
}

/* Header */
.header {
    text-align: center;
    padding: 24px 0;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
}

.header h1 {
    font-size: 1.75rem;
    color: var(--primary-dark);
    font-weight: 700;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 24px;
}

/* Progress Section */
.progress-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.progress-ring-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 24px;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 12;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.current-intake {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1;
}

.goal-text {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 4px;
}

.percentage {
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 4px;
}

/* Drink Button */
.drink-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

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

.drink-btn:active {
    transform: translateY(0);
}

.drink-icon {
    font-size: 1.3rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Quick Add Buttons */
.quick-add {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.quick-add-btn {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
}

.quick-add-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

.quick-add-btn[data-amount="-1"] {
    color: var(--danger-color);
}

.quick-add-btn[data-amount="-1"]:hover {
    background: #ffeaea;
    border-color: var(--danger-color);
}

/* Stats Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

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

.stat-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Chart Section */
.chart-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.chart-section h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.weekly-chart {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 120px;
    padding: 0 8px;
}

.chart-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
    justify-content: flex-end;
}

.bar-fill {
    width: 70%;
    max-width: 40px;
    background: linear-gradient(to top, var(--primary-color), var(--primary-light));
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    transition: height 0.5s ease;
}

.chart-bar.today .bar-fill {
    background: linear-gradient(to top, var(--accent-color), var(--primary-dark));
}

.bar-label {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
}

.chart-bar.today .bar-label {
    color: var(--primary-dark);
    font-weight: 600;
}

/* Log Section */
.log-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.log-section h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.log-list {
    max-height: 200px;
    overflow-y: auto;
}

.log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.log-item:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.log-amount {
    color: var(--primary-dark);
    font-weight: 600;
}

.empty-log {
    color: var(--text-light);
    text-align: center;
    padding: 24px 0;
    font-style: italic;
}

/* Settings Section */
.settings-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.settings-section h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.setting-group input[type="number"],
.setting-group input[type="time"],
.setting-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-color);
    transition: var(--transition);
}

.setting-group input:focus,
.setting-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-with-btns {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-btns input {
    text-align: center;
    flex: 1;
}

.adjust-btn {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border-color);
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

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

.schedule-inputs {
    display: flex;
    gap: 16px;
}

.time-input {
    flex: 1;
}

.time-input span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.sound-selector {
    display: flex;
    gap: 8px;
}

.sound-selector select {
    flex: 1;
}

.test-sound-btn {
    padding: 12px 16px;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.test-sound-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-group label:first-child {
    margin-bottom: 0;
}

.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-color);
    border-radius: 28px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* Setting Actions */
.setting-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.btn-secondary,
.btn-danger,
.btn-primary {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

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

.btn-danger {
    background: #ffeaea;
    color: var(--danger-color);
    border: 2px solid #ffd0d0;
}

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

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

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

/* Footer */
.footer {
    text-align: center;
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.footer a {
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    background: var(--card-bg);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    transition: transform 0.3s ease;
    border: 2px solid var(--primary-light);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast-icon {
    font-size: 1.5rem;
    animation: wobble 1s infinite;
}

@keyframes wobble {
    0%, 100% { transform: rotate(-10deg); }
    50% { transform: rotate(10deg); }
}

.toast-message {
    color: var(--text-primary);
    font-weight: 500;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0 0 0 12px;
    line-height: 1;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 20px;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    padding: 32px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 400px;
    width: 100%;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal.show .modal-content {
    transform: scale(1);
}

.celebration-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: celebrate 0.5s ease;
}

@keyframes celebrate {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.modal h2 {
    color: var(--primary-dark);
    margin-bottom: 12px;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .app-container {
        padding: 0 12px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .progress-ring-container {
        width: 160px;
        height: 160px;
    }

    .current-intake {
        font-size: 2.5rem;
    }

    .drink-btn {
        padding: 14px 36px;
        font-size: 1rem;
    }

    .stats-section {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 12px 8px;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .schedule-inputs {
        flex-direction: column;
        gap: 12px;
    }

    .setting-actions {
        flex-direction: column;
    }

    .quick-add-btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
}

/* Animation for adding water */
@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.drink-btn.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: var(--primary-light);
    border-radius: 50px;
    transform: translate(-50%, -50%) scale(1);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

.drink-btn {
    position: relative;
    overflow: hidden;
}

/* Scrollbar styling */
.log-list::-webkit-scrollbar {
    width: 6px;
}

.log-list::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 3px;
}

.log-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.log-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Print styles */
@media print {
    .drink-btn,
    .quick-add,
    .settings-section,
    .toast,
    .modal {
        display: none !important;
    }
}
