/* CSS Variables for theming */
:root {
    --primary-color: #00a8e8;
    --primary-dark: #007bb5;
    --primary-light: #62d4ff;
    --secondary-color: #003459;
    --accent-color: #00171f;
    --background-color: #f0f8ff;
    --card-background: #ffffff;
    --text-primary: #00171f;
    --text-secondary: #5a6c7d;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --border-radius: 12px;
    --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);
    --transition: all 0.3s ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--background-color) 0%, #e6f4ff 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

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

/* Header */
header {
    text-align: center;
    padding: 20px 0 30px;
}

header h1 {
    font-size: 2rem;
    color: var(--secondary-color);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

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

/* Section Styling */
section {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

section h2 {
    font-size: 1.25rem;
    color: var(--secondary-color);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Progress Ring Section */
.progress-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

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

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

.progress-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 12;
}

.progress-ring-fill {
    fill: none;
    stroke: white;
    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%);
    text-align: center;
}

.current-amount {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
}

.goal-amount {
    display: block;
    font-size: 1rem;
    opacity: 0.9;
}

.percentage {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 4px;
}

/* Quick Add Section */
.cup-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.cup-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 8px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.cup-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.cup-icon {
    font-size: 1.75rem;
    margin-bottom: 4px;
}

.cup-size {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.custom-add {
    display: flex;
    gap: 12px;
}

.custom-add input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

.custom-add input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-primary);
    border: 2px solid #e2e8f0;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

/* Log Section */
.log-entries {
    max-height: 200px;
    overflow-y: auto;
}

.log-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 8px;
}

.log-entry:last-child {
    margin-bottom: 0;
}

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

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

.log-delete {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    font-size: 1.25rem;
    opacity: 0.6;
    transition: var(--transition);
}

.log-delete:hover {
    opacity: 1;
}

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

/* Settings Section */
.settings-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 20px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.setting-item input,
.setting-item select {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

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

/* Toggle Switch */
.toggle-container {
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

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

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

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

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

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

/* History Section */
.history-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.week-range {
    font-weight: 600;
    color: var(--text-secondary);
}

.history-chart {
    margin-bottom: 20px;
}

.history-bars {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 150px;
    padding: 0 8px;
    gap: 8px;
}

.history-bar {
    flex: 1;
    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;
    position: relative;
}

.history-bar.goal-reached {
    background: linear-gradient(to top, var(--success-color), #34d399);
}

.history-bar.today {
    box-shadow: 0 0 0 2px var(--primary-color);
}

.bar-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary-color);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.history-bar:hover .bar-tooltip {
    opacity: 1;
}

.history-labels {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    gap: 8px;
}

.history-label {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-label.today {
    font-weight: 700;
    color: var(--primary-color);
}

.history-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat {
    text-align: center;
    padding: 16px;
    background: #f8fafc;
    border-radius: var(--border-radius);
}

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

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Footer */
footer {
    text-align: center;
    padding: 24px 0;
    margin-top: auto;
}

footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

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

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--secondary-color);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: transform 0.3s ease;
}

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

.toast.hidden {
    transform: translateX(-50%) translateY(100px);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 90%;
    width: 360px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.modal-content h3 {
    color: var(--secondary-color);
    margin-bottom: 8px;
}

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

.modal-content .btn-primary {
    display: block;
    width: 100%;
    margin-bottom: 12px;
}

.modal-content .btn-secondary {
    display: block;
    width: 100%;
}

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

    header h1 {
        font-size: 1.5rem;
    }

    section {
        padding: 16px;
    }

    .cup-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .history-stats {
        grid-template-columns: 1fr;
    }

    .history-controls {
        flex-direction: column;
        gap: 12px;
    }

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

    .current-amount {
        font-size: 2rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .cup-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse {
    animation: pulse 0.3s ease;
}

@keyframes ripple {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Scrollbar Styling */
.log-entries::-webkit-scrollbar {
    width: 6px;
}

.log-entries::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.log-entries::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.log-entries::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
