/* ============================================
   RESET ET STYLES DE BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #ecf0f1;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
}

/* ============================================
   LAYOUT PRINCIPAL (EJS)
   ============================================ */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

.app-header h1 {
    font-size: 24px;
    margin: 0;
}

.header-nav {
    display: flex;
    gap: 20px;
}

.header-nav a {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 5px;
    transition: background 0.2s;
}

.header-nav a:hover {
    background: rgba(255,255,255,0.2);
}

.header-nav a.active {
    background: rgba(255,255,255,0.3);
    font-weight: bold;
}

.header-nav a.logout-btn {
    background: rgba(220, 53, 69, 0.8);
    margin-left: 10px;
}

.header-nav a.logout-btn:hover {
    background: rgba(220, 53, 69, 1);
}

.app-sidebar {
    position: fixed;
    left: 0;
    top: 70px;
    width: 250px;
    height: calc(100vh - 70px);
    background: #2c3e50;
    color: white;
    padding: 20px;
    overflow-y: auto;
}

.sidebar-nav h3 {
    margin-bottom: 15px;
    font-size: 14px;
    text-transform: uppercase;
    color: #bdc3c7;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
}

.sidebar-nav li {
    margin-bottom: 5px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    text-decoration: none;
    padding: 12px 15px;
    border-radius: 5px;
    transition: background 0.2s;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.2);
    font-weight: bold;
}

.sidebar-footer {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    font-size: 12px;
    color: #95a5a6;
    text-align: center;
}

.app-content {
    margin-left: 250px;
    padding: 30px;
    min-height: calc(100vh - 70px);
    background: #ecf0f1;
}

/* ============================================
   PAGE ACCUEIL (HOME)
   ============================================ */
.home-view {
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.welcome-section {
    text-align: center;
    margin-bottom: 50px;
}

.welcome-section h1 {
    font-size: 36px;
    color: #333;
    margin-bottom: 10px;
}

.welcome-section .subtitle {
    font-size: 18px;
    color: #666;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 50px;
}

.dashboard-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    text-align: center;
}

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

.cave-card {
    border-top: 4px solid #8B0000;
}

.contact-card {
    border-top: 4px solid #667eea;
}

.card-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.dashboard-card h2 {
    font-size: 24px;
    color: #333;
    margin-bottom: 10px;
}

.dashboard-card p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}

.card-stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    padding: 20px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat strong {
    font-size: 28px;
    color: #667eea;
}

.stat span {
    font-size: 13px;
    color: #999;
}

.quick-actions {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 40px;
}

.quick-actions h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 22px;
}

.action-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.2);
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    text-decoration: none;
    transition: background 0.2s;
    backdrop-filter: blur(10px);
}

.action-btn:hover {
    background: rgba(255,255,255,0.3);
}

.action-icon {
    font-size: 20px;
}

.recent-section {
    margin-top: 40px;
}

.recent-section h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 22px;
}

.recent-wines {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.recent-wine-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
}

.recent-wine-card h4 {
    margin: 10px 0;
    color: #333;
    font-size: 16px;
}

.recent-wine-card p {
    color: #666;
    font-size: 13px;
    margin: 5px 0;
}

.recent-wine-card .price {
    display: inline-block;
    background: #f0f0f0;
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
    color: #667eea;
    margin-top: 10px;
}

/* ============================================
   PAGE CAVE (WINES)
   ============================================ */
.cave-view {
    padding: 20px;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.cave-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    color: white;
    padding: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.stat-icon {
    font-size: 40px;
    margin-right: 15px;
}

.stat-info h3 {
    margin: 0;
    font-size: 28px;
    font-weight: bold;
}

.stat-info p {
    margin: 5px 0 0 0;
    font-size: 14px;
    opacity: 0.9;
}

.filters-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-bar {
    margin-bottom: 15px;
}

.search-bar input {
    width: 100%;
    max-width: 400px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.filter-buttons, .filter-status {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.filter-btn, .status-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover, .status-btn:hover {
    background: #f0f0f0;
}

.filter-btn.active, .status-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.wines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.wine-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

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

.wine-type-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    color: white;
}

.wine-type-badge.rouge {
    background: #8B0000;
}

.wine-type-badge.blanc {
    background: #FFD700;
    color: #333;
}

.wine-type-badge.rosé {
    background: #FF69B4;
}

.wine-type-badge.pétillant {
    background: #FFE135;
    color: #333;
}

.consumed-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    background: #4CAF50;
    color: white;
}

.wine-header {
    margin-bottom: 15px;
    padding-right: 80px;
}

.wine-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.wine-vintage {
    margin-top: 5px;
}

.wine-vintage .year {
    display: inline-block;
    background: #f0f0f0;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: bold;
    color: #666;
}

.wine-details {
    margin: 15px 0;
}

.wine-detail {
    display: flex;
    align-items: center;
    margin: 8px 0;
    font-size: 14px;
    color: #555;
}

.wine-detail .icon {
    margin-right: 8px;
    font-size: 16px;
}

.wine-purchase {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 5px;
}

.purchase-info {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #666;
}

.purchase-price {
    font-size: 18px;
    color: #667eea;
}

.wine-comment {
    margin: 10px 0;
    padding: 10px;
    background: #fff9e6;
    border-left: 3px solid #FFC107;
    font-size: 13px;
    color: #666;
}

.wine-consumption {
    margin: 15px 0;
    padding: 10px;
    background: #e8f5e9;
    border-left: 3px solid #4CAF50;
    border-radius: 5px;
}

.consumption-date {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #2e7d32;
    font-weight: bold;
    margin-bottom: 5px;
}

.consumption-comment {
    font-size: 13px;
    color: #555;
    margin-top: 5px;
}

.wine-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    flex-wrap: wrap;
}

/* ============================================
   PAGE CONTACTS (PERSONS)
   ============================================ */
.contact-view {
    padding: 20px;
}

.persons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.person-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

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

.person-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.person-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: white;
    margin-right: 15px;
}

.person-info h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.person-email {
    margin: 5px 0 0 0;
    font-size: 14px;
    color: #666;
}

.person-stats {
    display: flex;
    justify-content: space-around;
    margin: 15px 0;
    padding: 15px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
}

.person-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

/* ============================================
   ÉTATS VIDES
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    grid-column: 1 / -1;
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 10px;
}

.empty-state .icon {
    font-size: 64px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 20px;
}

/* ============================================
   FORMULAIRES
   ============================================ */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #6c757d;
    font-size: 0.85rem;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ============================================
   BOUTONS
   ============================================ */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: #fefefe;
    margin: 3% auto;
    padding: 30px;
    border: 1px solid #888;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover,
.close:focus {
    color: #000;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

/* ============================================
   MESSAGES
   ============================================ */
.message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .app-sidebar {
        display: none;
    }
    
    .app-content {
        margin-left: 0;
        padding: 15px;
    }
    
    .header-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .header-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .welcome-section h1 {
        font-size: 28px;
    }
    
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
    
    .wines-grid {
        grid-template-columns: 1fr;
    }
    
    .persons-grid {
        grid-template-columns: 1fr;
    }
    
    .cave-stats {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}