/* ============================================
   CALYTIA THEME
   Fichier CSS centralisé pour tous les modules
   ============================================
   
   Variables CSS:
   --calytia-blue: #1e40af       (primary brand)
   --calytia-blue-light: #3b82f6 (accents)
   --calytia-blue-pale: #dbeafe  (backgrounds)
   --calytia-warm: #f59e0b       (CTA/accents)
   --calytia-warm-light: #fbbf24
   --calytia-warm-pale: #fef3c7
   --calytia-slate: #475569      (text secondary)
   ============================================ */

:root {
    /* === Calytia Brand === */
    --calytia-blue: #1e40af;
    --calytia-blue-light: #3b82f6;
    --calytia-blue-pale: #dbeafe;
    --calytia-warm: #f59e0b;
    --calytia-warm-light: #fbbf24;
    --calytia-warm-pale: #fef3c7;
    --calytia-slate: #475569;

    /* === Legacy aliases (backward-compat) === */
    --color-deep-night: #0f172a;
    --color-intense-blue: #3b82f6;
    --color-blue-grey: #475569;
    --color-light-blue: #f1f5f9;
    --color-green-accent: #059669;
    --color-orange: #f59e0b;
    --color-purple: #7c3aed;
    --color-red: #ef4444;
    --color-pink: #ec4899;
    --color-cyan: #06b6d4;
}

/* ============================================
   STATS CARDS
   ============================================ */
.db-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.db-stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--color-intense-blue);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.db-stat-card.blue { border-left-color: var(--color-intense-blue); }
.db-stat-card.green { border-left-color: var(--color-green-accent); }
.db-stat-card.orange { border-left-color: var(--color-orange); }
.db-stat-card.purple { border-left-color: var(--color-purple); }
.db-stat-card.red { border-left-color: var(--color-red); }
.db-stat-card.cyan { border-left-color: var(--color-cyan); }
.db-stat-card.pink { border-left-color: var(--color-pink); }

.db-stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
    color: var(--color-deep-night);
}

.db-stat-label {
    font-size: 0.8rem;
    color: var(--color-blue-grey);
    font-weight: 500;
}

.db-stat-trend {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.db-stat-trend.up { color: var(--color-green-accent); }
.db-stat-trend.down { color: var(--color-red); }

/* ============================================
   TOOLBAR
   ============================================ */
.db-toolbar {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.db-search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.db-search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    transition: all 0.2s;
    background: white;
}

.db-search-box input:focus {
    outline: none;
    border-color: var(--color-intense-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.db-search-box svg,
.db-search-box .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-blue-grey);
    width: 1.25rem;
    height: 1.25rem;
}

.db-filter-select {
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
    background-size: 1.25rem;
    cursor: pointer;
    appearance: none;
    min-width: 150px;
}

.db-filter-select:focus {
    outline: none;
    border-color: var(--color-intense-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ============================================
   BUTTONS
   ============================================ */
.db-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.db-btn-primary {
    background: linear-gradient(135deg, var(--color-intense-blue), #1d4ed8);
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.db-btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    color: white;
}

.db-btn-secondary {
    background: var(--color-light-blue);
    color: var(--color-deep-night);
    border: 1px solid #e2e8f0;
}

.db-btn-secondary:hover {
    background: #e2e8f0;
    color: var(--color-deep-night);
}

.db-btn-success {
    background: linear-gradient(135deg, var(--color-green-accent), #059669);
    color: white;
}

.db-btn-success:hover {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
}

.db-btn-danger {
    background: linear-gradient(135deg, var(--color-red), #dc2626);
    color: white;
}

.db-btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
}

.db-btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.db-btn svg {
    width: 1.125rem;
    height: 1.125rem;
}

/* ============================================
   CARDS
   ============================================ */
.db-card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: all 0.2s;
}

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

.db-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.db-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-deep-night);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.db-card-body {
    padding: 1.25rem;
}

.db-card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    background: var(--color-light-blue);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================
   GRID LAYOUTS
   ============================================ */
.db-grid {
    display: grid;
    gap: 1rem;
}

.db-grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.db-grid-3 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.db-grid-4 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

/* ============================================
   BADGES / STATUS
   ============================================ */
.db-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.db-badge-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.db-badge-green {
    background: #d1fae5;
    color: #059669;
}

.db-badge-orange {
    background: #fef3c7;
    color: #d97706;
}

.db-badge-red {
    background: #fee2e2;
    color: #dc2626;
}

.db-badge-purple {
    background: #ede9fe;
    color: #7c3aed;
}

.db-badge-gray {
    background: #f1f5f9;
    color: var(--color-blue-grey);
}

.db-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.db-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.db-status-dot.active { background: var(--color-green-accent); }
.db-status-dot.inactive { background: var(--color-blue-grey); }
.db-status-dot.pending { background: var(--color-orange); }
.db-status-dot.error { background: var(--color-red); }

/* ============================================
   ACTION BUTTONS (ICON BUTTONS)
   ============================================ */
.db-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: none;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    color: var(--color-blue-grey);
    text-decoration: none;
}

.db-action-btn:hover {
    background: var(--color-light-blue);
    color: var(--color-intense-blue);
    border-color: var(--color-intense-blue);
}

.db-action-btn.delete:hover {
    background: #fee2e2;
    color: var(--color-red);
    border-color: var(--color-red);
}

.db-action-btn.success:hover {
    background: #d1fae5;
    color: var(--color-green-accent);
    border-color: var(--color-green-accent);
}

.db-action-btn svg {
    width: 1.125rem;
    height: 1.125rem;
}

/* ============================================
   ICONS
   ============================================ */
.db-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.db-icon svg {
    width: 24px;
    height: 24px;
}

.db-icon-blue {
    background: linear-gradient(135deg, #dbeafe, #93c5fd);
    color: var(--color-deep-night);
}

.db-icon-green {
    background: linear-gradient(135deg, #d1fae5, #6ee7b7);
    color: var(--color-deep-night);
}

.db-icon-orange {
    background: linear-gradient(135deg, #fef3c7, #fcd34d);
    color: var(--color-deep-night);
}

.db-icon-purple {
    background: linear-gradient(135deg, #ede9fe, #c4b5fd);
    color: var(--color-deep-night);
}

.db-icon-red {
    background: linear-gradient(135deg, #fee2e2, #fca5a5);
    color: var(--color-deep-night);
}

/* ============================================
   TABLES
   ============================================ */
.db-table {
    width: 100%;
    border-collapse: collapse;
}

.db-table th {
    background: var(--color-light-blue);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-blue-grey);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
}

.db-table td {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.875rem;
    color: var(--color-deep-night);
}

.db-table tr:hover td {
    background: #f8fafc;
}

.db-table tr:last-child td {
    border-bottom: none;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.db-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
}

.db-empty-state svg {
    width: 4rem;
    height: 4rem;
    color: #cbd5e1;
    margin: 0 auto 1rem;
}

.db-empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-deep-night);
    margin-bottom: 0.5rem;
}

.db-empty-state p {
    color: var(--color-blue-grey);
    margin-bottom: 1.5rem;
}

/* ============================================
   AVATARS
   ============================================ */
.db-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.db-avatar-sm { width: 32px; height: 32px; }
.db-avatar-lg { width: 56px; height: 56px; }

.db-avatar-group {
    display: flex;
}

.db-avatar-group .db-avatar {
    margin-left: -0.5rem;
}

.db-avatar-group .db-avatar:first-child {
    margin-left: 0;
}

.db-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-intense-blue), #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

/* ============================================
   PROGRESS BARS
   ============================================ */
.db-progress {
    height: 8px;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
}

.db-progress-bar {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.db-progress-bar.blue { background: linear-gradient(90deg, var(--color-intense-blue), #60a5fa); }
.db-progress-bar.green { background: linear-gradient(90deg, var(--color-green-accent), #34d399); }
.db-progress-bar.orange { background: linear-gradient(90deg, var(--color-orange), #fbbf24); }
.db-progress-bar.red { background: linear-gradient(90deg, var(--color-red), #f87171); }

/* ============================================
   TABS
   ============================================ */
.db-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 1.5rem;
}

.db-tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-blue-grey);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.db-tab:hover {
    color: var(--color-intense-blue);
}

.db-tab.active {
    color: var(--color-intense-blue);
    border-bottom-color: var(--color-intense-blue);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.db-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.db-input:focus {
    outline: none;
    border-color: var(--color-intense-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.db-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-deep-night);
    margin-bottom: 0.5rem;
}

.db-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--color-intense-blue);
    cursor: pointer;
}

.db-toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.db-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.db-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #cbd5e1;
    border-radius: 24px;
    transition: 0.3s;
}

.db-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.db-toggle input:checked + .db-toggle-slider {
    background: var(--color-intense-blue);
}

.db-toggle input:checked + .db-toggle-slider:before {
    transform: translateX(20px);
}

/* ============================================
   TIMELINE
   ============================================ */
.db-timeline {
    position: relative;
    padding-left: 2rem;
}

.db-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}

.db-timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.db-timeline-item:last-child {
    padding-bottom: 0;
}

.db-timeline-dot {
    position: absolute;
    left: -1.625rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-intense-blue);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--color-intense-blue);
}

.db-timeline-dot.completed { background: var(--color-green-accent); box-shadow: 0 0 0 2px var(--color-green-accent); }
.db-timeline-dot.pending { background: var(--color-orange); box-shadow: 0 0 0 2px var(--color-orange); }
.db-timeline-dot.error { background: var(--color-red); box-shadow: 0 0 0 2px var(--color-red); }

/* ============================================
   ALERTS / NOTIFICATIONS
   ============================================ */
.db-alert {
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.db-alert-info {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    color: #1d4ed8;
}

.db-alert-success {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    color: #059669;
}

.db-alert-warning {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #d97706;
}

.db-alert-danger {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #dc2626;
}

.db-alert svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

/* ============================================
   DROPDOWN MENU
   ============================================ */
.db-dropdown {
    position: relative;
    display: inline-block;
}

.db-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    border: 1px solid #e2e8f0;
    min-width: 180px;
    z-index: 50;
    display: none;
}

.db-dropdown.open .db-dropdown-menu {
    display: block;
}

.db-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--color-deep-night);
    text-decoration: none;
    transition: background 0.2s;
}

.db-dropdown-item:hover {
    background: var(--color-light-blue);
}

.db-dropdown-item svg {
    width: 1rem;
    height: 1rem;
    color: var(--color-blue-grey);
}

.db-dropdown-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 0.5rem 0;
}

/* ============================================
   MODALS
   ============================================ */
.db-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.db-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.db-modal {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.db-modal-overlay.open .db-modal {
    transform: scale(1);
}

.db-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.db-modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-deep-night);
}

.db-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-blue-grey);
    transition: all 0.2s;
}

.db-modal-close:hover {
    background: var(--color-light-blue);
    color: var(--color-deep-night);
}

.db-modal-body {
    padding: 1.5rem;
}

.db-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ============================================
   PAGINATION
   ============================================ */
.db-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.db-page-btn {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-blue-grey);
    background: white;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.db-page-btn:hover {
    background: var(--color-light-blue);
    color: var(--color-intense-blue);
    border-color: var(--color-intense-blue);
}

.db-page-btn.active {
    background: var(--color-intense-blue);
    color: white;
    border-color: var(--color-intense-blue);
}

.db-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .db-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .db-search-box {
        min-width: 100%;
    }
    
    .db-grid-2,
    .db-grid-3,
    .db-grid-4 {
        grid-template-columns: 1fr;
    }
    
    .db-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .db-card-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .db-stats {
        grid-template-columns: 1fr;
    }
}
