@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - Light Mode (Updated) */
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --primary-color: #10b981; /* Emerald */
    --primary-hover: #059669;
    --accent-color: #8b5cf6; /* Violet */
    --card-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.05);
    --error-color: #ef4444;
    --error-bg: #fef2f2;
    --danger-color: #dc2626;
    --shadow-color: rgba(15, 23, 42, 0.08);

    --font-family: 'Outfit', 'Inter', sans-serif;
    --transition-speed: 0.25s;
    --border-radius: 16px;
    --max-width: 1100px;
}

[data-theme="dark"] {
    /* Color Palette - Dark Mode (Premium Slate) */
    --bg-color: #020617;
    --surface-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --primary-color: #10b981;
    --primary-hover: #34d399;
    --accent-color: #a78bfa;
    --card-bg: rgba(30, 41, 59, 0.5);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color var(--transition-speed), color var(--transition-speed);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-color);
}

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

.animate-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Layout */
.content-wrapper {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 15px -3px var(--shadow-color), 0 4px 6px -4px var(--shadow-color);
}

/* Navbar */
/* Navbar */
.navbar {
    position: sticky;
    top: 1rem;
    margin: 0 1rem;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    transition: all var(--transition-speed);
}

@media (max-width: 700px) {
    .navbar {
        flex-direction: column;
        gap: 1.25rem;
        padding: 1.5rem;
        align-items: stretch;
        text-align: center;
    }
    .navbar .search-container {
        margin: 0 !important;
    }
    .navbar div {
        justify-content: center;
    }
}

/* Flex Utilities */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.mx-4 { margin-left: 1rem; margin-right: 1rem; }
.text-center { text-align: center; }
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }

/* Grid System */
.grid {
    display: grid;
    gap: 1.5rem;
    margin-top: 2rem;
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
@media (min-width: 640px) { .grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Cards & Components */
.wine-card {
    display: flex;
    flex-direction: row; /* Changed from column to row */
    overflow: hidden;
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-height: 180px; /* Ensure a consistent minimum height */
}

@media (max-width: 600px) {
    .wine-card {
        flex-direction: column;
    }
}

.wine-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px var(--shadow-color), 0 8px 10px -6px var(--shadow-color);
    border-color: var(--primary-color);
}

.wine-card-img-container {
    width: 160px; /* Fixed width for the thumbnail in row layout */
    background: var(--glass-border);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    display: flex; /* Centering for width:auto image */
    align-items: center;
    justify-content: center;
}

@media (max-width: 600px) {
    .wine-card-img-container {
        width: 100%;
        height: 200px;
    }
}

.wine-card-img {
    display: block;
    width: auto; /* Shrink to fit aspect ratio */
    height: auto;
    max-width: 90%; /* Leave a small gap */
    max-height: 90%;
    object-fit: contain; /* Respect aspect ratio */
    border-radius: 12px;
    transition: transform var(--transition-speed);
}

.wine-card:hover .wine-card-img {
    transform: scale(1.05);
}

.wine-card.card-draft {
    background: rgba(15, 23, 42, 0.08); /* Darker, more muted background */
    border: 1px dashed var(--error-color);
    opacity: 0.9;
}

[data-theme="dark"] .wine-card.card-draft {
    background: rgba(0, 0, 0, 0.3);
}

.wine-card.card-draft .wine-card-img {
    filter: grayscale(1) contrast(0.8);
}

.wine-card.card-draft:hover {
    opacity: 1;
    border-style: solid;
}

.wine-card-content {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.wine-card-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.wine-card-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.wine-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
}

/* Badge */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive {
    background: #475569;
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.btn-icon:hover {
    background: var(--glass-border);
}

.btn-theme-toggle {
    font-size: 1.6rem !important;
}

.btn-icon-prominent {
    background: var(--primary-color);
    color: white;
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-icon-prominent:hover {
    background: var(--primary-hover);
    transform: scale(1.1) rotate(5deg);
}

.spin-on-click:active {
    animation: spin-once 0.5s ease-out;
}

@keyframes spin-once {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* FAB */
.fab {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 2.2rem;
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

/* Search Bar */
.search-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 1rem 1.5rem 1rem 3rem;
    border-radius: 9999px;
    border: 1px solid var(--glass-border);
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    font-size: 1rem;
    color: var(--text-color);
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Form Styles */
.form-section {
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.form-title {
    font-size: 1.125rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.05);
    color: var(--text-color);
    transition: all var(--transition-speed);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(90deg, var(--glass-border) 25%, rgba(0,0,0,0.1) 50%, var(--glass-border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Status dots */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.active { background: #10b981; }
.status-dot.inactive { background: #ef4444; }
