:root {
    --coffee-brown: #6F4E37;
    --coffee-light: #A67C52;
    --cream: #F5E6D3;
    --dark: #2C2416;
    --white: #FFFFFF;
    --shadow: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--cream) 0%, #E8D5C4 100%);
    min-height: 100vh;
    padding: 1rem;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

header {
    background: var(--coffee-brown);
    color: var(--white);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
}

.card {
    background: var(--white);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px var(--shadow);
}

h1, h2 {
    color: var(--coffee-brown);
}

h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--white);
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow);
}

.toggle-btn {
    flex: 1;
    background: transparent;
    color: var(--coffee-brown);
    border: 2px solid transparent;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
    display: block;
}

.toggle-btn:hover {
    background: var(--cream);
}

.toggle-btn.active {
    background: var(--coffee-brown);
    color: var(--white);
}

/* Forms */
input[type="text"],
input[type="email"],
input[type="date"],
select,
textarea,
.form-control {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 2px solid #E0E0E0;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--coffee-brown);
}

button,
.btn {
    background: var(--coffee-brown);
    color: var(--white);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    font-weight: 600;
}

button:hover {
    background: var(--dark);
}

button:disabled {
    background: #CCC;
    cursor: not-allowed;
}

.icon-btn {
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Photo Upload */
.photo-upload {
    text-align: center;
    margin-bottom: 1rem;
}

.upload-btn {
    display: inline-block;
    background: var(--coffee-light);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.upload-btn:hover {
    background: var(--coffee-brown);
}

.photo-preview {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 3px solid var(--coffee-light);
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 12px var(--shadow);
}

.photo-controls {
    margin-top: 0.5rem;
}

.remove-photo-btn {
    background: #D32F2F;
    color: var(--white);
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    display: inline-block;
}

.remove-photo-btn:hover {
    background: #B71C1C;
}

/* Rating Input */
.rating-input {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.rating-input input[type="range"] {
    flex: 1;
    margin: 0;
}

.rating-input span {
    font-weight: bold;
    color: var(--coffee-brown);
    min-width: 2rem;
    text-align: center;
}

/* Taste Grid */
.taste-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.taste-grid label {
    font-size: 0.875rem;
    color: var(--dark);
    font-weight: 500;
}

.taste-grid input[type="range"] {
    width: 100%;
    margin: 0.25rem 0;
}

/* Coffee Bags Grid */
#bags-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.bag-item {
    border: 2px solid #E0E0E0;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    background: var(--white);
    position: relative;
}

.bag-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px var(--shadow);
}

.bag-item.finished {
    border-color: #388E3C;
    background: linear-gradient(to bottom, var(--white) 0%, #F1F8E9 100%);
}

.bag-item.finished::before {
    content: '✓ Finished';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #388E3C;
    color: var(--white);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.bag-photo {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 1rem;
}

.bag-photo.placeholder {
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.bag-info h3 {
    color: var(--coffee-brown);
    margin-bottom: 0.25rem;
}

.bag-info p {
    font-size: 0.875rem;
    color: #666;
    margin: 0.25rem 0;
}

.bag-rating {
    color: var(--coffee-brown);
    font-weight: bold;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--cream);
    border-radius: 4px;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--coffee-brown);
}

.stat-label {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Filter Controls */
.filter-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #E0E0E0;
}

.filter-section:last-of-type {
    border-bottom: none;
}

.filter-section h3 {
    color: var(--coffee-brown);
    font-size: 1rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.filter-option:hover {
    background: var(--cream);
}

.filter-option input[type="radio"],
.filter-option input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.filter-option span {
    flex: 1;
    font-size: 1rem;
    color: var(--dark);
}

/* Autocomplete */
.autocomplete-container {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}

.autocomplete-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #E0E0E0;
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 0;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 2px solid var(--coffee-brown);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px var(--shadow);
}

.autocomplete-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.autocomplete-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #F0F0F0;
    transition: background 0.2s;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--cream);
}

/* Country Insights */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.insight-card {
    background: var(--cream);
    border-radius: 8px;
    padding: 1.5rem;
}

.insight-card h3 {
    color: var(--coffee-brown);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.insight-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.insight-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--white);
    border-radius: 6px;
}

.insight-item .rank {
    font-weight: 700;
    color: var(--coffee-brown);
    min-width: 2rem;
}

.insight-item .country-name {
    flex: 1;
    font-weight: 600;
}

.insight-item .rating,
.insight-item .count {
    color: var(--coffee-brown);
    font-weight: 600;
}

/* Detail Page */
.modal-detail-photo {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.modal-detail-photo.placeholder {
    height: 200px;
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
}

.modal-detail-section {
    margin-bottom: 1.5rem;
}

.modal-detail-section h3 {
    color: var(--coffee-brown);
    font-size: 1rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.modal-detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #F0F0F0;
}

.modal-detail-label {
    font-weight: 600;
    color: #666;
}

.modal-detail-value {
    color: var(--dark);
}

.modal-stars {
    color: var(--coffee-brown);
    font-size: 1.2rem;
}

.modal-taste-bars {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-taste-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-taste-label {
    min-width: 80px;
    font-weight: 500;
    color: #666;
}

.modal-taste-progress {
    flex: 1;
    height: 8px;
    background: #E0E0E0;
    border-radius: 4px;
    overflow: hidden;
}

.modal-taste-fill {
    height: 100%;
    background: var(--coffee-brown);
}

.modal-taste-value {
    min-width: 30px;
    text-align: right;
    font-weight: 600;
    color: var(--coffee-brown);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.modal-actions button {
    flex: 1;
}

.finish-btn {
    background: #388E3C;
}

.delete-btn {
    background: #D32F2F;
}

.roast-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.roast-badge.light,
.roast-badge.mediumlight {
    background: #FFF9E6;
    color: #F57F17;
}

.roast-badge.medium,
.roast-badge.mediumdark {
    background: #EFEBE9;
    color: #795548;
}

.roast-badge.dark {
    background: #3E2723;
    color: #FFFFFF;
}

/* Auth */
.auth-description {
    text-align: center;
    font-size: 1.1rem;
    color: var(--coffee-brown);
    margin: 1rem 0;
    font-weight: 500;
}

.auth-info {
    text-align: center;
    font-size: 0.95rem;
    color: var(--dark);
    margin: 1rem 0 1.5rem;
    line-height: 1.5;
    padding: 1rem;
    background: var(--cream);
    border-radius: 6px;
}

.token-instruction {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--dark);
}

.secondary-btn {
    background: transparent;
    color: var(--coffee-brown);
    border: 2px solid var(--coffee-brown);
    margin-top: 1rem;
}

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

.error {
    background: #FFEBEE;
    color: #C62828;
    padding: 1rem;
    border-radius: 4px;
    text-align: center;
}

.success {
    background: #E8F5E9;
    color: #2E7D32;
    padding: 1rem;
    border-radius: 4px;
    text-align: center;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: #999;
    font-style: italic;
}

/* Stats Page */
.time-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--cream);
    border-radius: 6px;
}

.detailed-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--cream);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px var(--shadow);
}

.stat-card h3 {
    color: var(--coffee-brown);
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 700;
}

.stat-card-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--coffee-brown);
    margin-bottom: 0.5rem;
}

.stat-card-label {
    font-size: 0.9rem;
    color: #666;
}

.favorite-roasters-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.roaster-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--white);
    border-radius: 6px;
}

.roaster-name {
    font-weight: 600;
}

.roaster-count {
    color: var(--coffee-light);
    font-weight: 600;
}

/* Responsive */
@media (max-width: 600px) {
    .taste-grid {
        grid-template-columns: 1fr;
    }

    #bags-container {
        grid-template-columns: 1fr;
    }

    .view-toggle {
        flex-direction: column;
    }

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