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

:root {
    --primary-color: #8B4513;
    --secondary-color: #D2691E;
    --accent-color: #CD853F;
    --bg-color: #1a1a1a;
    --card-bg: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --success-color: #4CAF50;
    --danger-color: #f44336;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.app-container {
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: max(env(safe-area-inset-top), 20px) 20px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.add-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px;
    padding-bottom: 80px;
    overflow-y: auto;
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Coffee Grid */
.coffee-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.coffee-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.coffee-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-lg);
}

.coffee-card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

.coffee-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.coffee-card-content {
    padding: 16px;
}

.coffee-card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.coffee-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.coffee-badge {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(139, 69, 19, 0.3);
    border: 1px solid var(--primary-color);
    color: var(--accent-color);
}

.coffee-card-date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.coffee-card-rating {
    font-size: 16px;
    margin-top: 8px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 14px;
}

/* Form */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.form-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.detail-actions {
    display: flex;
    gap: 8px;
}

.back-btn, .edit-btn, .share-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-btn {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.back-btn:active, .edit-btn:active, .share-btn:active {
    transform: scale(0.95);
}

.back-btn:active, .edit-btn:active {
    background: var(--border-color);
}

.share-btn:active {
    opacity: 0.8;
}

.coffee-form {
    max-width: 600px;
    margin: 0 auto;
}

.form-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.section-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--accent-color);
}

/* Photo Upload */
.photo-upload {
    margin-bottom: 16px;
}

.photo-preview {
    width: 100%;
    height: 200px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    background: rgba(139, 69, 19, 0.1);
}

.photo-preview:active {
    transform: scale(0.98);
    border-color: var(--accent-color);
}

.photo-placeholder {
    font-size: 16px;
    color: var(--text-secondary);
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Form Inputs */
input[type="text"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(205, 133, 63, 0.2);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.input-group {
    margin-bottom: 12px;
}

.input-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Recommended Parameters */
.recommended-params {
    background: rgba(139, 69, 19, 0.2);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.6;
}

.recommended-params strong {
    color: var(--accent-color);
}

/* Sliders */
.slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.slider-group label {
    flex: 0 0 100px;
    font-size: 14px;
    color: var(--text-secondary);
}

.slider-group input[type="range"] {
    flex: 1;
    height: 6px;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.slider-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.slider-value {
    flex: 0 0 30px;
    text-align: center;
    font-weight: 600;
    color: var(--accent-color);
}

/* Rating Stars */
.rating-stars {
    display: flex;
    gap: 8px;
    font-size: 32px;
}

.star {
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--border-color);
}

.star.active {
    color: #FFD700;
}

.star:active {
    transform: scale(1.2);
}

/* Buttons */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

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

.btn-secondary:active {
    transform: scale(0.98);
    background: var(--border-color);
}

.btn-danger {
    width: 100%;
    margin-top: 20px;
    background: var(--danger-color);
    color: white;
}

.btn-danger:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* Detail View */
.coffee-detail {
    max-width: 600px;
    margin: 0 auto;
}

.detail-image {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: 16px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.detail-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.detail-section h3 {
    font-size: 18px;
    color: var(--accent-color);
    margin-bottom: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.detail-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

.taste-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.taste-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.taste-label {
    flex: 0 0 100px;
    font-size: 14px;
    color: var(--text-secondary);
}

.taste-bar {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.taste-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.taste-value {
    flex: 0 0 30px;
    text-align: center;
    font-weight: 600;
    color: var(--accent-color);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: max(env(safe-area-inset-bottom), 8px);
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.3);
    z-index: 99;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    transition: all 0.2s ease;
}

.nav-item.active {
    color: var(--accent-color);
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .coffee-grid {
        grid-template-columns: 1fr;
    }
    
    .main-content {
        padding: 16px;
    }
}

/* iOS Specific Enhancements */
@supports (-webkit-touch-callout: none) {
    .app-container {
        padding-top: env(safe-area-inset-top);
    }
    
    input,
    textarea,
    select {
        font-size: 16px; /* Prevent zoom on focus */
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Loading Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 0.8s linear infinite;
}
