/* Wine Collection App - Mobile-First Responsive Styles */

/* CSS Variables for consistent theming */
:root {
    --primary-color: #722F37;
    --secondary-color: #C4956B;
    --accent-color: #E6B800;
    --background-color: #FEFEFE;
    --card-background: #FFFFFF;
    --text-color: #2C2C2C;
    --text-light: #666666;
    --border-color: #E0E0E0;
    --success-color: #28A745;
    --warning-color: #FFC107;
    --error-color: #DC3545;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

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

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

/* Header Styles */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.header-main {
    text-align: center;
    flex: 1;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 0.9rem;
    opacity: 0.9;
}

.header-actions {
    margin-left: auto;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    text-decoration: none;
    color: white;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-nav button {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-width: 120px;
}

.tab-nav button.active {
    background: var(--primary-color);
    color: white;
}

.tab-nav button:hover {
    background: var(--primary-color);
    color: white;
}

.tab-nav button:first-child {
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
}

.tab-nav button:last-child {
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

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

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

/* Cards */
.card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.card h3 {
    color: var(--secondary-color);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--card-background);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(114, 47, 55, 0.1);
}

.form-control.error {
    border-color: var(--error-color);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    cursor: pointer;
}

/* Button Styles */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
    min-width: 120px;
}

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

.btn-primary:hover {
    background: #5a252a;
    transform: translateY(-2px);
}

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

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

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

.btn-warning {
    background: var(--warning-color);
    color: var(--text-color);
}

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-width: 80px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* File Upload Styles */
.file-upload {
    position: relative;
    display: inline-block;
    width: 100%;
}

.file-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-upload-label {
    display: block;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    text-align: center;
    background: var(--background-color);
    transition: var(--transition);
    cursor: pointer;
}

.file-upload-label:hover {
    border-color: var(--primary-color);
    background: rgba(114, 47, 55, 0.05);
}

.file-upload-label.dragover {
    border-color: var(--primary-color);
    background: rgba(114, 47, 55, 0.1);
}

.camera-btn {
    width: 100%;
    margin-bottom: 1rem;
}

/* Image Preview */
.image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    box-shadow: var(--shadow);
}

/* Wine Grid */
.wine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.wine-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.wine-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.wine-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.wine-card-content {
    padding: 1rem;
}

.wine-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.wine-details {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.wine-rating {
    display: flex;
    align-items: center;
    margin: 0.5rem 0;
}

.stars {
    color: var(--accent-color);
    margin-right: 0.5rem;
}

.wine-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table tr:hover {
    background: rgba(114, 47, 55, 0.05);
}

/* Search and Filter */
.search-filter {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-filter input,
.search-filter select {
    flex: 1;
    min-width: 200px;
}

/* Pairing Results */
.pairing-result {
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    margin: 1rem 0;
    background: rgba(114, 47, 55, 0.05);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.pairing-result ul {
    margin-left: 1rem;
    padding-left: 0.5rem;
}

.pairing-result li {
    margin-bottom: 0.25rem;
}

/* Pairing Guidelines Styling */
.example-descriptions .example {
    background: rgba(114, 47, 55, 0.03);
    padding: 0.75rem;
    margin: 0.5rem 0;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--secondary-color);
}

.example-descriptions .example strong {
    color: var(--primary-color);
}

.pairing-tips h4 {
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.pairing-tips h4:first-child {
    margin-top: 0;
}

.pairing-tips ul {
    margin-left: 1rem;
    padding-left: 0.5rem;
}

.pairing-tips li {
    margin-bottom: 0.5rem;
}

.pairing-score {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.score-excellent { background: var(--success-color); color: white; }
.score-very-good { background: #20A745; color: white; }
.score-good { background: var(--accent-color); color: var(--text-color); }
.score-fair { background: var(--warning-color); color: var(--text-color); }
.score-poor { background: var(--error-color); color: white; }

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-light);
}

.spinner {
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

/* Button Loading States */
.btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn .spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
    margin-right: 0.5rem;
    display: inline-block;
    vertical-align: middle;
}

.button-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.button-loading .spinner {
    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(40, 167, 69, 0.1);
    border-color: var(--success-color);
    color: #155724;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    border-color: var(--warning-color);
    color: #856404;
}

.alert-error {
    background: rgba(220, 53, 69, 0.1);
    border-color: var(--error-color);
    color: #721c24;
}

/* Duplicate Wine Alert Styling */
.alert h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.alert details {
    margin-top: 0.5rem;
}

.alert summary {
    cursor: pointer;
    font-weight: 500;
    padding: 0.25rem 0;
}

.alert summary:hover {
    color: var(--primary-color);
}

.alert .btn {
    margin-right: 0.5rem;
    margin-top: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

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

    .tab-nav {
        margin-bottom: 1rem;
    }

    .tab-nav button {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
        min-width: 100px;
    }

    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .wine-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .search-filter {
        flex-direction: column;
        gap: 0.5rem;
    }

    .search-filter input,
    .search-filter select {
        min-width: auto;
    }

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

    .table-responsive {
        font-size: 0.9rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.75rem;
    }

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

    .tab-nav button {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
        min-width: 80px;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        min-width: 100px;
    }

    .form-control {
        padding: 0.5rem;
    }

    .card {
        padding: 0.75rem;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-primary { color: var(--primary-color); }
.text-secondary { color: var(--secondary-color); }
.text-muted { color: var(--text-light); }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }

.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

.w-100 { width: 100%; }

/* Print Styles */
@media print {
    .header,
    .tab-nav,
    .btn,
    .wine-actions {
        display: none;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}