/* =====================================================
   Ferme du Hibou - Styles Principaux
   ===================================================== */

:root {
    --primary: #2d7a3a;
    --primary-dark: #1e5428;
    --primary-light: #4caf60;
    --secondary: #8bc34a;
    --accent: #ff6f00;
    --accent-light: #ffa726;
    --bg: #f4f7f0;
    --card-bg: #ffffff;
    --text: #2c3e2d;
    --text-light: #5a7060;
    --border: #c8dfc9;
    --shadow: 0 4px 20px rgba(45, 122, 58, 0.12);
    --shadow-hover: 0 8px 32px rgba(45, 122, 58, 0.22);
    --radius: 14px;
    --radius-sm: 8px;
    --transition: 0.25s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── Header ─────────────────────────────────────────── */
header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.header-content { position: relative; z-index: 1; }

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

header .subtitle {
    margin-top: 0.5rem;
    font-size: 1rem;
    opacity: 0.88;
    position: relative;
    z-index: 1;
}

.logo-icon { font-size: 2rem; margin-bottom: 0.5rem; display: block; }

/* ── Container ───────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; }

/* ── Info Section ────────────────────────────────────── */
.info-section {
    display: flex;
    gap: 1rem;
    padding: 1.5rem 2rem;
    flex-wrap: wrap;
}

.info-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: var(--text-light);
    flex: 1;
    min-width: 200px;
}

.info-card i { color: var(--primary); font-size: 1.1rem; }

/* ── Form / Sections ─────────────────────────────────── */
form, .orders-section-wrapper {
    padding: 0 2rem 3rem;
}

form h2, .section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 2rem 0 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* ── Category Sections ───────────────────────────────── */
.category-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.category-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.6rem;
    margin-bottom: 1rem;
}

.subcategory {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 1rem 0 0.5rem;
}

/* ── Products Grid ───────────────────────────────────── */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.product-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    transition: var(--transition);
}

.product-item:hover { border-color: var(--primary-light); background: #f0f7f0; }
.product-item.active { border-color: var(--primary); background: #e8f5e9; }

.product-item label {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
}

.product-item input[type="number"] {
    width: 60px;
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: center;
    color: var(--text);
    background: white;
    transition: var(--transition);
}

.product-item input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 122, 58, 0.15);
}

.product-subtotal {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-dark);
    min-width: 50px;
    text-align: right;
}

/* ── Total ───────────────────────────────────────────── */
.total-section {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 1.5rem 2rem;
    border-radius: var(--radius);
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    box-shadow: var(--shadow-hover);
}

.total-section h3 { font-size: 1.3rem; font-weight: 600; }
#grandTotal { font-size: 2rem; font-weight: 700; color: #a5d6a7; }

/* ── Customer Form ───────────────────────────────────── */
.customer-form {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.customer-form h2 {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--primary-dark);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 0.35rem;
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: white;
    transition: var(--transition);
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 122, 58, 0.15);
}

/* ── Submit ──────────────────────────────────────────── */
.submit-section { text-align: center; margin-top: 1.5rem; }

.submit-btn {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    box-shadow: var(--shadow);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.submit-btn:active { transform: translateY(0); }

/* ── Success Message ─────────────────────────────────── */
.success-message {
    text-align: center;
    background: var(--card-bg);
    border: 2px solid var(--primary-light);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    margin: 2rem;
    box-shadow: var(--shadow-hover);
}

.success-message i { font-size: 4rem; color: var(--primary); margin-bottom: 1rem; display: block; }
.success-message h3 { font-size: 1.6rem; color: var(--primary-dark); margin-bottom: 0.5rem; }
.success-message p { color: var(--text-light); margin-bottom: 1.5rem; }

.btn-new-order {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.75rem;
    border-radius: 50px;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-new-order:hover { background: var(--primary-dark); transform: translateY(-1px); }

/* ══════════════════════════════════════════════════════
   MANAGER STYLES
   ══════════════════════════════════════════════════════ */

/* ── Login Screen ────────────────────────────────────── */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--secondary) 100%);
    padding: 2rem;
}

.login-card {
    background: white;
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    text-align: center;
}

.login-card .owl-icon { font-size: 4rem; margin-bottom: 0.5rem; }
.login-card h2 { color: var(--primary-dark); margin-bottom: 0.3rem; }
.login-card p { color: var(--text-light); font-size: 0.9rem; margin-bottom: 2rem; }

.login-card .form-group { text-align: left; margin-bottom: 1.2rem; }

.login-error {
    background: #fff3f3;
    border: 1px solid #ffcdd2;
    color: #c62828;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: none;
}

.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 2.5rem; }
.toggle-pw {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
}

.login-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    border: none;
    padding: 0.9rem;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.login-btn:hover { background: linear-gradient(135deg, var(--primary), var(--primary-light)); transform: translateY(-1px); }

.login-hint {
    margin-top: 1.2rem;
    font-size: 0.8rem;
    color: var(--text-light);
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 0.6rem;
}

/* ── Manager Controls ────────────────────────────────── */
.manager-controls {
    padding: 1.5rem 2rem 0;
}

.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.stat-card i { font-size: 2rem; color: var(--primary); }
.stat-card h3 { font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card p { font-size: 0.8rem; color: var(--text-light); margin-top: 0.2rem; }

/* ── Filter Section ──────────────────────────────────── */
.filter-section {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.search-box {
    flex: 1;
    min-width: 220px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 0.9rem;
    color: var(--text-light);
}

.search-box input {
    width: 100%;
    padding: 0.7rem 0.9rem 0.7rem 2.4rem;
    border: 1.5px solid var(--border);
    border-radius: 50px;
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 122, 58, 0.15);
}

.refresh-btn, .export-btn, .logout-btn {
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    color: var(--text);
    padding: 0.65rem 1.2rem;
    border-radius: 50px;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition);
    font-family: inherit;
}

.refresh-btn:hover { border-color: var(--primary); color: var(--primary); }
.export-btn { border-color: var(--accent); color: var(--accent); }
.export-btn:hover { background: var(--accent); color: white; }
.logout-btn { border-color: #ef5350; color: #ef5350; }
.logout-btn:hover { background: #ef5350; color: white; }

/* ── Orders Container ────────────────────────────────── */
.orders-container { padding: 0 2rem 3rem; }

.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.loading i { font-size: 2rem; margin-bottom: 0.5rem; display: block; }

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
}

.empty-state i { font-size: 4rem; color: var(--border); margin-bottom: 1rem; display: block; }
.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }

/* ── Orders Table ────────────────────────────────────── */
.orders-table-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table thead { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); color: white; }
.orders-table th {
    padding: 1rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.orders-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

.orders-table tr:last-child td { border-bottom: none; }
.orders-table tbody tr:hover { background: #f0f7f0; }

/* ── Status Badge ────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-en-attente  { background: #fff3e0; color: #e65100; }
.status-validee     { background: #e3f2fd; color: #1565c0; }
.status-prete       { background: #e8f5e9; color: #2e7d32; }
.status-livree      { background: #f3e5f5; color: #6a1b9a; }
.status-annulee     { background: #ffebee; color: #c62828; }

/* ── Action Buttons ──────────────────────────────────── */
.action-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    color: var(--text-light);
    margin-right: 0.3rem;
}

.action-btn:hover { border-color: var(--primary); color: var(--primary); }
.action-btn.delete:hover { border-color: #ef5350; color: #ef5350; }

/* ── Status Select ───────────────────────────────────── */
.status-select {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    background: white;
    color: var(--text);
    transition: var(--transition);
}

.status-select:focus { outline: none; border-color: var(--primary); }

/* ── Modal ───────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal .close {
    position: absolute;
    top: 1rem;
    right: 1.2rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
    line-height: 1;
}

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

.modal h3 { color: var(--primary-dark); margin-bottom: 1rem; font-size: 1.2rem; }
.modal-section { margin-bottom: 1.2rem; }
.modal-section h4 { color: var(--text-light); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem; }

.modal-items {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.modal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.modal-item:last-child { border-bottom: none; }
.modal-item .qty { font-weight: 600; color: var(--primary); }
.modal-item .price { color: var(--text-light); }

.modal-total {
    text-align: right;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 2px solid var(--primary-light);
}

.notes-area {
    width: 100%;
    min-height: 80px;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

.notes-area:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,122,58,0.15); }

.save-notes-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: var(--transition);
    font-family: inherit;
}

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

/* ── Pagination ──────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.page-btn {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--text);
}

.page-btn:hover, .page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
    header h1 { font-size: 1.6rem; }
    .info-section, form { padding: 1rem; }
    .orders-container { padding: 0 1rem 2rem; }
    .manager-controls { padding: 1rem; }

    .products-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-section { grid-template-columns: 1fr; }

    .orders-table th:nth-child(4),
    .orders-table td:nth-child(4) { display: none; }

    .total-section { flex-direction: column; text-align: center; }
}

@media (max-width: 500px) {
    .orders-table thead { display: none; }
    .orders-table tr { display: block; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
    .orders-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--bg);
        font-size: 0.85rem;
    }
    .orders-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-light);
        font-size: 0.78rem;
        min-width: 100px;
    }
}
