/* app/static/css/style.css */

/* ========== DESIGN SYSTEM — ZMIENNE MARKI DEVISTOR ========== */
:root {
    /* Kolory marki (z logo DeviStor) */
    --primary-color: #1A5FA8;        /* Bleu royal — texte logo */
    --primary-hover-color: #134d8c;  /* Hover sombre */
    --color-accent: #D4A017;         /* Or — signe $ du logo */
    --color-accent-hover: #b8890f;

    /* UI neutrals */
    --secondary-color: #6c757d;
    --secondary-hover-color: #5a6268;
    --success-color: #28a745;
    --success-hover-color: #218838;
    --danger-color: #dc3545;
    --danger-hover-color: #c82333;

    /* Surfaces & textes */
    --light-gray-color: #f8f9fa;
    --medium-gray-color: #e9ecef;
    --dark-gray-color: #6c757d;
    --border-color: #e2e8f0;
    --text-color: #2D3748;
    --text-muted-color: #718096;
    --body-bg: #F8F9FA;
    --container-bg: #ffffff;

    /* Typographie */
    --font-family-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Formes & ombres */
    --border-radius: 0.375rem;
    --border-radius-md: 0.75rem;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --spacing-unit: 1rem;
}

/* ========== OGÓLNE RESETY I USTAWIENIA ========== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-sans-serif);
    background-color: var(--body-bg);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
    text-align: center;
    margin-top: 0;
    margin-bottom: var(--spacing-unit);
    font-weight: 400;
}
h1 { font-size: 1.6rem; color: var(--primary-color); font-weight: 600; }
h2 { font-size: 1.2rem; margin-bottom: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 500; }

a {
    color: var(--primary-color);
    text-decoration: none;
}
a:hover {
    color: var(--primary-hover-color);
    /* Usunięto text-decoration: underline, bo Bootstrap obsługuje to dla linków w .btn */
}

/* ========== FORMULARZE (Podstawowe) ========== */
/* Usunięto większość stylów formularzy - Bootstrap je zapewnia */
/* Zachowujemy tylko te, które mogą być specyficzne dla projektu */

form {
    margin-top: calc(var(--spacing-unit) * 1.5); /* Zachowujemy margines górny dla formularzy */
}

/* Układ przycisków formularza - można nadal używać, jeśli potrzebne */
.form-buttons-horizontal {
    display: flex;
    gap: calc(var(--spacing-unit) / 2); 
    margin-top: calc(var(--spacing-unit) * 1.5);
    align-items: center;
}

/* ========== PRZYCISKI ========== */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 600;
    border-radius: var(--border-radius);
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover-color);
    border-color: var(--primary-hover-color);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
}


/* ========== DASHBOARD V2 ========== */
.dashboard-v2 {
    margin-top: var(--spacing-unit);
}

.dashboard-welcome h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #1A2A44;
    margin: 0;
}
.dashboard-welcome p {
    font-size: 1rem;
}

/* Layout: mobile = kolumna, desktop = 2 kolumny (karty + widgety) */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 992px) {
    .dashboard-layout {
        grid-template-columns: minmax(0, 1fr) 320px;
        align-items: start;
    }
}

/* ===== Karty główne ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}
@media (max-width: 480px) {
    .dashboard-grid {
        gap: 0.9rem;
    }
}

.dashboard-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background-color: #E8F1FB;
    border: 1px solid rgba(26, 95, 168, 0.08);
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(26, 95, 168, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
    min-height: 200px;
}
.dashboard-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(26, 95, 168, 0.14);
}

.dashboard-card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 0.75rem;
    padding: 1.5rem 1rem 0.75rem;
    text-decoration: none;
    color: inherit;
}
.dashboard-card-body:hover {
    text-decoration: none;
    color: inherit;
}

.dashboard-card-icon {
    font-size: 3rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}
@media (max-width: 480px) {
    .dashboard-card-icon { font-size: 2.4rem; }
    .dashboard-card { min-height: 160px; }
}

.dashboard-card-label {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1A2A44;
    text-align: center;
}

.dashboard-card-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin: 0 auto 1rem;
    padding: 0.35rem 0.9rem;
    background: #fff;
    border: 1px solid rgba(26, 95, 168, 0.2);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--primary-color);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.dashboard-card-action:hover {
    background: var(--primary-color);
    color: #fff;
    text-decoration: none;
}

/* Kolorowe warianty ikon */
.dashboard-card--devis    .dashboard-card-icon { color: #1A5FA8; }
.dashboard-card--factures .dashboard-card-icon { color: #2E7D32; }
.dashboard-card--services .dashboard-card-icon { color: #D4A017; }
.dashboard-card--clients  .dashboard-card-icon { color: #6A1B9A; }

.dashboard-card--devis    { background: linear-gradient(135deg, #E8F1FB 0%, #D9E7F7 100%); }
.dashboard-card--factures { background: linear-gradient(135deg, #E8F5E9 0%, #D4EAD7 100%); border-color: rgba(46, 125, 50, 0.12); box-shadow: 0 2px 8px rgba(46, 125, 50, 0.06); }
.dashboard-card--services { background: linear-gradient(135deg, #FFF8E1 0%, #FBEFC2 100%); border-color: rgba(212, 160, 23, 0.18); box-shadow: 0 2px 8px rgba(212, 160, 23, 0.08); }
.dashboard-card--clients  { background: linear-gradient(135deg, #F3E5F5 0%, #E5D0EA 100%); border-color: rgba(106, 27, 154, 0.12); box-shadow: 0 2px 8px rgba(106, 27, 154, 0.06); }

/* ===== Widgety (aside) ===== */
.dashboard-aside {
    flex-direction: column;
    gap: 1.25rem;
}

.dashboard-widget {
    background: #fff;
    border: 1px solid #E5E9F0;
    border-radius: 14px;
    padding: 1rem 1.1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.dashboard-widget-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1A2A44;
    margin: 0 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #EEF1F5;
}

.dashboard-widget-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.dashboard-widget-list li { margin: 0; }
.dashboard-widget-list li + li { margin-top: 0.35rem; }
.dashboard-widget-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.4rem 0.1rem;
    font-size: 0.85rem;
    color: #2D3748;
    text-decoration: none;
    border-bottom: 1px dashed #EEF1F5;
}
.dashboard-widget-list li:last-child a { border-bottom: none; }
.dashboard-widget-list a:hover { color: var(--primary-color); }
.fw-600 { font-weight: 600; }

.dashboard-stats {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.dashboard-stats li {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
}
.dashboard-stats-icon {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.95rem;
}
.dashboard-stats-label {
    color: #4A5568;
    font-weight: 500;
}
.dashboard-stats-value {
    font-weight: 700;
    color: #1A2A44;
    white-space: nowrap;
}

.dashboard-buttons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); 
    gap: var(--spacing-unit);
    margin-top: calc(var(--spacing-unit) * 1.5);
    margin-bottom: calc(var(--spacing-unit) * 3); 
}

/* Styl przycisków na dashboardzie - zostawiamy, bo są specyficzne */
.dashboard-button-small {
    display: block; 
    background-color: var(--success-color);
    color: white;
    text-align: center;
    padding: var(--spacing-unit); 
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.3s ease, transform 0.1s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.dashboard-button-small:hover {
    background-color: var(--success-hover-color);
    color: white;
    text-decoration: none;
    transform: translateY(-2px); 
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.logout-form {
    text-align: right; 
    margin-top: var(--spacing-unit); 
}

/* ========== TABELA — STYL GLOBALNY ========== */
.table {
    font-size: 0.85rem;
}
.table > thead > tr > th {
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}
.table > tbody > tr {
    transition: background-color 0.12s;
}
.table > tbody > tr:hover {
    background-color: rgba(26, 95, 168, 0.04);
}
/* Usunięto .styled-table i .table-container - używamy klas Bootstrapa: .table, .table-responsive */
/* Zachowujemy .actions-cell jeśli potrzebne do specyficznego stylowania odstępów */
/* (Bootstrap używa paddingu w komórkach td, th) */
/* Można ewentualnie dostosować styl komórki akcji jeśli domyślny Bootstrapa nie pasuje */
/* Komórka z akcjami - MOŻNA USUNĄĆ jeśli wyrównanie tekstu i odstępy Bootstrapa są OK */
.actions-cell { 
    white-space: nowrap; 
    /* text-align: right; - teraz używamy text-center w HTML */
}
/* Odstępy między przyciskami w actions-cell - Bootstrap załatwia to inaczej */
/* Można ewentualnie dodać mały gap przez klasy Bootstrapa w HTML (np. `gap-1`) lub zostawić tę regułę, jeśli jest potrzebna */
.actions-cell > * { 
   margin-left: calc(var(--spacing-unit) / 3); /* Zmniejszony odstęp, jeśli zostaje */
}
.actions-cell > *:first-child { margin-left: 0; }


/* ========== LINKI I PRZYCISKI AKCJI (w tabelach/edycji) ========== */
/* Usunięto .edit-link, .delete-link - używamy przycisków .btn .btn-sm */
/* Usunięto .edit-top-bar, .delete-x - nie używamy już tego przycisku */
/* Usunięto .back-button - używamy .btn .btn-secondary */

/* Formularz w jednej linii (np. przycisk usuwania w tabeli) */
/* Zmienione na klasę Bootstrapa 'd-inline' w HTML, ale można zostawić jako fallback */
.inline-form { 
    display: inline;
    margin: 0;
}

/* ========== FLASH MESSAGES ========== */
/* Usunięto definicje .alert-* - używamy stylów Bootstrapa */

/* ========== GÓRNY PASEK (JĘZYK + POMOC) ========== */
/* Zostawiamy style dla niestandardowego górnego paska */
.top-bar {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--spacing-unit) / 2) calc(var(--spacing-unit) * 1.5);
    background-color: var(--primary-color);
    color: #fff;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--primary-hover-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
    flex-wrap: nowrap;
}

.top-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.top-bar-logo {
    height: 36px;
    width: auto;
    display: block;
}

.top-left,
.top-right {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) / 2);
    flex-wrap: nowrap; 
}

.top-left form.inline-form {
    margin: 0; 
}
.top-nav-link {
    color: #fff;
    font-weight: 500;
    text-decoration: none;
    font-family: inherit;
    padding: 0.25rem 0.5rem;
    transition: color 0.3s ease;
    background: none; 
    border: none; 
    cursor: pointer; 
    font-size: 1.1rem; 
}
.top-nav-link:hover {
    color: #D4A017;
    text-decoration: none;
}
.top-left span {
    color: var(--border-color);
    margin: 0 calc(var(--spacing-unit)/4);
}
.top-right a.top-nav-link {
    font-size: 0.9rem; 
}

/* ========== PROFILE VIEW ========== */
/* Zostawiamy style dla widoku profilu */
.profile-view-container {
    padding: calc(var(--spacing-unit) * 1.5);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--light-gray-color);
}
.profile-logo { margin-bottom: calc(var(--spacing-unit) * 1.5); }
.profile-logo img {
    max-width: 200px;
    max-height: 120px;
    border: 1px solid var(--border-color);
    padding: 5px;
    display: block; 
    background-color: white;
}
.profile-details p { margin-bottom: 0.75rem; line-height: 1.6; }
.profile-details strong { display: inline-block; min-width: 160px; font-weight: 600; } 
.profile-actions { margin-top: calc(var(--spacing-unit) * 1.5); }

/* ========== BADGES & STATUS ========== */
/* Zostawiamy style dla badge i statusów */
.badge {
    display: inline-block;
    padding: .35em .65em; 
    font-size: .75em; 
    font-weight: 700; 
    line-height: 1;
    color: #fff; 
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: .375rem; 
  }
  
.status-draft { background-color: var(--secondary-color, #6c757d); } 
.status-sent { background-color: var(--primary-color, #0d6efd); }   
.status-accepted { background-color: var(--success-color, #198754); } 
.status-rejected { background-color: var(--danger-color, #dc3545); }  
/* .status-archived { background-color: #adb5bd; } */
  
/* ========== LINKI W ALERTACH ========== */
/* Styl dla linku w komunikacie 'alert-info' */
.alert-info a.alert-link { 
    font-weight: bold;
    color: inherit; 
    text-decoration: underline;
}
.alert-info a.alert-link:hover {
    filter: brightness(90%);
}
  
/* ========== WYRÓWNANIA TEKSTU ========== */
/* Usunięto, bo Bootstrap ma klasy .text-end, .text-center */
/* .styled-table th.text-end, */
/* .styled-table td.text-end { text-align: right; } */
/* .styled-table th.text-center, */
/* .styled-table td.text-center { text-align: center; } */

/* ========== STYLES PRZENIESIONE Z SZABLONÓW (POSPRZĄTANE) ========== */
/* Usunięto większość, bo są pokryte przez Bootstrap lub inne reguły */

.text-muted { color: #6c757d !important; } /* Klasa pomocnicza Bootstrapa, !important może być potrzebne jeśli jest konflikt */
/* Usunięto .mb-4, .mt-4 - używamy klas Bootstrapa */
/* Usunięto nadpisania .btn, .btn-primary, etc. */

/* Klasy Card - Bootstrap je ma, ale można zostawić te podstawowe, jeśli chcesz je lekko zmienić */
.card { 
    border: 1px solid var(--border-color); /* Używamy zmiennej */
    border-radius: var(--border-radius); /* Używamy zmiennej */
    margin-bottom: 1.5rem; 
}
.card-header { 
    background-color: var(--light-gray-color); /* Używamy zmiennej */
    padding: .75rem 1rem; /* Lekko dostosowany padding */
    font-weight: 600; /* Pogrubienie */
    border-bottom: 1px solid var(--border-color); /* Używamy zmiennej */
}
.card-body { 
    padding: 1rem; 
}

/* Style dla Select2 - Zostawiamy na razie, ale rozważ użycie motywu Bootstrap 5 */
.select2-container--bootstrap-5 .select2-selection--single {
    height: calc(1.5em + .75rem + 2px) !important;
    padding: .375rem .75rem !important;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-color); /* Używamy zmiennej */
    background-color: var(--container-bg); /* Używamy zmiennej */
    border: 1px solid var(--border-color); /* Używamy zmiennej */
    border-radius: var(--border-radius); /* Używamy zmiennej */
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 1.5 !important;
    padding-left: 0 !important;
    color: var(--text-color); /* Używamy zmiennej */
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: calc(1.5em + .75rem) !important;
    position: absolute;
    top: 1px; 
    right: 1px;
    width: 20px;
}
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: #86b7fe !important; 
    box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25) !important;
}
.select2-container--bootstrap-5 .select2-dropdown {
    border-color: #86b7fe; 
}
.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
    border: 1px solid var(--border-color); /* Używamy zmiennej */
    border-radius: var(--border-radius); /* Używamy zmiennej */
}
.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--primary-color); /* Używamy zmiennej */
    color: white;
}

/* Style dla strony logowania */
.login-container form { 
  max-width: 400px; 
  margin-left: auto;
  margin-right: auto;
}
.login-container p { 
  text-align: center;
  margin-top: 1.5rem;
}
/* Usunięto .w-100 - Bootstrap ma tę klasę */

/* Usunięto .button-row - niepotrzebne przy Bootstrapie */

/* === KONIEC CZYSZCZENIA === */

/* ZAWIJANIE TYTULOW W KOLUMACH TABELI */

.th-nowrap {
    white-space: nowrap;
}

.preserve-whitespace {
    white-space: pre-line; /* Zachowuje nowe linie, zwija sekwencje spacji, pozwala na zawijanie wierszy */
    /* Alternatywnie można użyć:
       white-space: pre-wrap;  <- Zachowuje nowe linie ORAZ sekwencje spacji
       white-space: pre;       <- Zachowuje wszystko, ale NIE zawija wierszy (może rozpychać tabelę)
       'pre-line' jest zazwyczaj najlepszym wyborem dla opisów z textarea. */
}

.mobile-note {
  opacity: 0.85;
}

/* Kolor ikonki edycji — kolor marki */
.text-purple {
    color: #1A5FA8 !important;
}

/* Status "Facturé" — kolor marki */
.status-invoiced {
    background-color: #1A5FA8;
    color: white;
}

.bi-receipt:hover {
    color: #134d8c !important;
    transform: scale(1.2);
    transition: 0.2s;
}

