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

:root {
    --primary: #6B2D5C;
    --primary-dark: #4A1E3E;
    --secondary: #B8860B;
    --background: #FAFAFA;
    --surface: #FFFFFF;
    --text: #2C2C2C;
    --text-light: #666666;
    --border: #E0E0E0;
    --success: #2E7D32;
    --warning: #F57C00;
    --error: #C62828;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header & Navigation */
header {
    background: var(--surface);
    padding: 20px 30px;
    margin-bottom: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 28px;
    margin-bottom: 15px;
    color: var(--primary);
}

nav {
    display: flex;
    gap: 10px;
}

nav a {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text);
    border-radius: 6px;
    transition: all 0.3s;
    font-weight: 500;
}

nav a:hover {
    background: var(--background);
}

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

nav a.logout {
    margin-left: auto;
    color: var(--error);
}

/* Toolbar */
.toolbar {
    background: var(--surface);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.search-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.search-filters input,
.search-filters select {
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

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

.btn-block {
    width: 100%;
}

/* Bottles Grid */
.bottles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.bottle-card {
    background: var(--surface);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
    border-left: 4px solid var(--primary);
    cursor: pointer;
}

.bottle-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.bottle-card.status-depassee_ideale {
    border-left-color: var(--error);
}

.bottle-card.status-depassee {
    border-left-color: var(--warning);
}

.bottle-card.status-ideale {
    border-left-color: var(--success);
}

.bottle-card.status-normale {
    border-left-color: var(--secondary);
}

.bottle-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.bottle-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.bottle-vintage {
    font-size: 24px;
    font-weight: 700;
    color: var(--secondary);
}

.bottle-info {
    margin-bottom: 10px;
}

.bottle-info-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 14px;
}

.bottle-info-label {
    color: var(--text-light);
    font-weight: 500;
}

.bottle-stock {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.bottle-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.bottle-actions button {
    flex: 1;
    padding: 6px;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-light);
}

.btn-consume {
    border-color: var(--success);
    color: var(--success);
}

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

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

.btn-edit {
    border-color: var(--secondary);
    color: var(--secondary);
}

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

.btn-delete {
    border-color: var(--error);
    color: var(--error);
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 30px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-light);
    cursor: pointer;
}

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

.modal-content h2 {
    margin-bottom: 25px;
    color: var(--primary);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--surface);
    padding: 25px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card h3 {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
}

.dashboard-section {
    background: var(--surface);
    padding: 25px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.dashboard-section h2 {
    margin-bottom: 20px;
    color: var(--primary);
}

.region-group {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--background);
    border-radius: 6px;
}

.region-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 10px;
}

.sous-region-group {
    margin-left: 20px;
    margin-bottom: 10px;
}

.sous-region-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 5px;
}

.appellation-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 15px;
    margin-left: 40px;
    background: var(--surface);
    border-radius: 4px;
    margin-bottom: 5px;
}

.appellation-name {
    color: var(--text);
}

.appellation-stock {
    color: var(--primary);
    font-weight: 600;
}

/* History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.history-item {
    background: var(--surface);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.history-wine {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

.history-date {
    color: var(--text-light);
    font-size: 14px;
}

.history-details {
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* Settings */
.settings {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.settings-section {
    background: var(--surface);
    padding: 25px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.settings-section h2 {
    margin-bottom: 20px;
    color: var(--primary);
    font-size: 20px;
}

.param-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.param-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--background);
    border-radius: 6px;
}

.param-name {
    font-weight: 500;
}

.param-delete {
    background: var(--error);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.param-delete:hover {
    background: #8B1A1A;
}

.add-param {
    display: flex;
    gap: 10px;
}

.add-param input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--surface);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 10px;
}

.login-box h2 {
    text-align: center;
    color: var(--text);
    margin-bottom: 30px;
    font-size: 20px;
}

.alert {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-error {
    background: #FFEBEE;
    color: var(--error);
    border: 1px solid #FFCDD2;
}

/* Responsive */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .bottles-grid {
        grid-template-columns: 1fr;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-filters {
        flex-direction: column;
    }
    
    nav {
        flex-wrap: wrap;
    }
}

/* Modal de visualisation */
.modal-view {
    max-width: 900px;
}

.view-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

.view-header h2 {
    color: var(--primary);
    margin: 0;
}

.view-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.view-field {
    padding: 10px;
    background: var(--background);
    border-radius: 6px;
    font-size: 14px;
}

.view-field strong {
    color: var(--text-light);
    display: block;
    margin-bottom: 3px;
    font-size: 13px;
}

.view-section {
    padding: 15px;
    background: var(--background);
    border-radius: 6px;
}

.view-section strong {
    color: var(--primary);
    font-size: 15px;
}

@media (max-width: 768px) {
    .view-grid {
        grid-template-columns: 1fr;
    }
}

/* Timeline de dégustation */
.timeline-container {
    margin-top: 10px;
    padding: 20px 0;
}

.timeline-track {
    position: relative;
    height: 80px;
    background: var(--border);
    border-radius: 8px;
    margin: 40px 0;
}

.timeline-zone {
    position: absolute;
    height: 100%;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.timeline-zone-normale {
    background: rgba(184, 134, 11, 0.2);
    border: 2px solid var(--secondary);
    z-index: 1;
}

.timeline-zone-ideale {
    background: rgba(46, 125, 50, 0.3);
    border: 2px solid var(--success);
    z-index: 2;
}

.timeline-zone-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    padding: 0 10px;
}

.timeline-marker {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    z-index: 3;
}

.timeline-marker-line {
    width: 2px;
    height: 80px;
    background: var(--text-light);
}

.timeline-marker-label {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.timeline-current {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    z-index: 4;
}

.timeline-current-line {
    width: 3px;
    height: 80px;
    background: var(--primary);
    box-shadow: 0 0 10px rgba(107, 45, 92, 0.5);
}

.timeline-current-label {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    background: var(--surface);
    padding: 2px 8px;
    border-radius: 4px;
    box-shadow: var(--shadow);
}
