/**
 * GestPrint Base CSS
 * Variables globals i estils base per a tota l'aplicació
 * Importar després de Bootstrap 5
 */

/* ===========================================
   VARIABLES GLOBALS
   =========================================== */

:root {
    --gp-font-size: 11px;
    --bs-body-color: #333;
}
[data-bs-theme="dark"] {
    --bs-body-color: #CCC;
}
/* DINS UNA CARD */
.card {
    --bs-card-color: #333;
}
[data-bs-theme="dark"] .card {
    --bs-card-color: #CCC;
}

/* Cursor wait global (aplicar classe 'wait' al body) */
body.wait, body.wait * {
    cursor: wait !important;
}

/* ===========================================
   TAMANY DE FONT GLOBAL
   =========================================== */

body {
    font-size: var(--gp-font-size);
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Elements de text */
p, span, label, small,
li, dt, dd,
th, td {
    font-size: var(--gp-font-size);
}

/* Formularis */
input, select, textarea, button,
.form-control, .form-select, .btn {
    font-size: var(--gp-font-size);
}

/* Navegació */
.navbar {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.nav-link, .dropdown-item,
.breadcrumb-item, .breadcrumb-item a {
    font-size: var(--gp-font-size);
    font-weight: 400;
}

/* Cards */
.card-title, .card-text {
    font-size: var(--gp-font-size);
}

/* Encapçalaments (proporcionals) */
h1 { font-size: calc(var(--gp-font-size) * 2); }
h2 { font-size: calc(var(--gp-font-size) * 1.75); }
h3 { font-size: calc(var(--gp-font-size) * 1.5); }
h4 { font-size: calc(var(--gp-font-size) * 1.25); }
h5, h6 { font-size: var(--gp-font-size); font-weight: 400; }

/* ===========================================
   FORMULARIS - ASPECTE ESTÀNDARD
   =========================================== */

/* Card body: fons lleugerament més fosc que els inputs */
.card-body {
    background-color: var(--bs-secondary-bg);
}

/* Inputs: fons clar, borders més visibles */
.form-control, .form-select {
    background-color: var(--bs-body-bg);
    border: 1px solid rgba(var(--bs-emphasis-color-rgb), 0.4);
}

/* Input group: consistència amb els inputs */
.input-group-text {
    background-color: var(--bs-tertiary-bg);
    border: 1px solid rgba(var(--bs-emphasis-color-rgb), 0.4);
}

/* Dropdowns dins formularis: mateix aspecte que els inputs */
.dropdown-toggle.btn-outline-secondary {
    background-color: var(--bs-body-bg);
    border: 1px solid rgba(var(--bs-emphasis-color-rgb), 0.4);
}

.dropdown-toggle.btn-outline-secondary {
    color: var(--bs-body-color);
}

.dropdown-toggle.btn-outline-secondary:hover,
.dropdown-toggle.btn-outline-secondary:focus {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* ===========================================
   ESTILS GENERALS
   =========================================== */

/* Inputs readonly més discrets */
.form-control[readonly] {
    background-color: transparent;
}

/* Camps numèrics alineats a la dreta */
.numeric {
    text-align: right;
}

/* ===========================================
   CARDS (Bootstrap 5)
   =========================================== */

.card {
    margin-bottom: 1rem;
}

.card-header {
    padding: 0.5rem 1rem;
}

.card-body {
    padding: 0.75rem 1rem;
}

.card-title {
    margin-bottom: 0;
}

/* ===========================================
   BREADCRUMB - Mínim modern
   =========================================== */

.breadcrumb-minimal {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    margin: 0 0 0.5rem 0;
    list-style: none;
}

.breadcrumb-minimal .minimal-item a,
.breadcrumb-minimal .minimal-item span {
    display: inline-flex;
    align-items: center;
    font-size: var(--gp-font-size);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-minimal .minimal-item a {
    color: var(--bs-secondary-color);
}

.breadcrumb-minimal .minimal-item a:hover {
    color: var(--bs-primary);
}

.breadcrumb-minimal .minimal-item a:hover i {
    color: var(--bs-primary);
}

.breadcrumb-minimal .minimal-item.active span {
    color: var(--bs-emphasis-color);
    font-weight: 500;
}

.breadcrumb-minimal .minimal-item i {
    margin-right: 0.35rem;
    font-size: 12px;
    color: var(--bs-secondary-color);
    opacity: 0.7;
}

.breadcrumb-minimal .minimal-separator {
    color: var(--bs-border-color);
    font-size: 11px;
}

/* Fallback per breadcrumbs antics */
.breadcrumb {
    font-size: var(--gp-font-size);
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    background-color: transparent;
}

/* ===========================================
   NAV TABS
   =========================================== */

.nav-tabs .nav-link {
    font-size: var(--gp-font-size);
    padding: 0.5rem 1rem;
}

/* ===========================================
   MODALS
   =========================================== */

.modal .modal-body {
    background-color: var(--bs-secondary-bg);
}
.modal .modal-body:last-child {
    border-radius: 0 0 var(--bs-modal-border-radius) var(--bs-modal-border-radius);
}

.modal label {
    font-size: var(--gp-font-size);
}

/* Inputs dins modals: borders més visibles */
.modal .form-control,
.modal .form-select {
    background-color: var(--bs-body-bg);
    border: 1px solid rgba(var(--bs-emphasis-color-rgb), 0.4);
}

/* ===========================================
   PROGRESS BARS (consumibles)
   =========================================== */

.progress {
    height: 20px;
    margin-bottom: 0.5rem;
}

.progress-bar {
    font-size: calc(var(--gp-font-size) * 0.85);
}

/* Colors personalitzats per consumibles (iguals a l'app antiga) */
.progress-bar-black {
    background-color: black;
}

.progress-bar-cyan {
    background-color: cyan;
}

.progress-bar-magenta {
    background-color: magenta;
}

.progress-bar-yellow {
    background-color: #E0E000;
}

.progress-bar-violet {
    background-color: blueviolet;
}

/* Barres de consumibles - estil unificat */
.progress.progress-cell {
    margin: 0;
    height: 18px;
    position: relative;
    --bs-progress-bg: #b0b0b0;
}

.progress-cell .progress-bar {
    font-size: 11px;
    line-height: 18px;
}

.progress-cell .progress-text {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 11px;
    line-height: 18px;
    font-weight: 600;
    z-index: 1;
    color: #fff;
}

.progress-cell .progress-label {
    position: absolute;
    left: 0;
    padding-left: 0.4rem;
    font-size: 11px;
    line-height: 18px;
    font-weight: 700;
    z-index: 2;
    color: #fff;
}

/* Fons clar (part "wasted"): versions clares dels colors de consumible */
.progress-cell.progress-cyan { --bs-progress-bg: rgba(0, 255, 255, 0.25); }
.progress-cell.progress-magenta { --bs-progress-bg: rgba(255, 0, 255, 0.25); }
.progress-cell.progress-yellow { --bs-progress-bg: rgba(224, 224, 0, 0.25); }
.progress-cell.progress-violet { --bs-progress-bg: rgba(138, 43, 226, 0.25); }

.progress-cell.progress-cyan .progress-text,
.progress-cell.progress-cyan .progress-label,
.progress-cell.progress-magenta .progress-text,
.progress-cell.progress-magenta .progress-label,
.progress-cell.progress-yellow .progress-text,
.progress-cell.progress-yellow .progress-label,
.progress-cell.progress-violet .progress-text,
.progress-cell.progress-violet .progress-label {
    color: #333;
}

.cell-vermell { color: #ff3030 !important; font-weight: bold; }
.cell-taronja { color: #fd7e14 !important; font-weight: bold; }

/* Text dins progress bars (legacy) */
.progress-bar .gris {
    color: #fff;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
}

.progress-bar-yellow .gris {
    color: #333;
    text-shadow: none;
}

/* ===========================================
   CARD HEADER COLORS (consumibles)
   =========================================== */

.card-header.panelblack {
    color: white;
    background-color: rgba(0, 0, 0, 0.90);
}

.card-header.panelcyan {
    color: #000000;
    background-color: rgba(0, 255, 255, 0.5);
}

.card-header.panelmagenta {
    color: #000000;
    background-color: rgba(255, 0, 255, 0.5);
}

.card-header.panelyellow {
    color: #000000;
    background-color: rgba(255, 255, 0, 0.5);
}

.card-header.panelgreen {
    color: #000000;
    background-color: rgba(40, 255, 80, 0.5);
}

/* ===========================================
   WIDGET CARDS (Paràmetres / Configuració)
   =========================================== */

/* Widget card base */
.widget-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease-in-out;
    overflow: hidden;
}

.widget-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* Widget card header */
.widget-card .card-header {
    border-bottom: none;
    padding: 0.4rem 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-card .card-header .widget-icon {
    font-size: 1.1em;
    opacity: 0.9;
}

.widget-card .card-header .card-title,
.widget-card .card-header h5,
.widget-card .card-header h6,
.widget-card .card-header span {
    font-weight: 600;
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.2;
}

/* Widget card body */
.widget-card .card-body {
    padding: 1rem;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

.widget-card .card-body label,
.widget-card .card-body .form-check-label,
.widget-card .card-body .form-label,
.widget-card .card-body .form-check-personalize,
.widget-card .card-body .slider-label,
.widget-card .card-body span,
.widget-card .card-body p {
    color: var(--bs-body-color);
}

/* Widget colors - colors purs de tinta (sense degradat) */
.widget-card.widget-black .card-header {
    background: rgba(0, 0, 0, 0.90);
    color: #fff;
}

.widget-card.widget-cyan .card-header {
    background: cyan;
    color: #000;
}

.widget-card.widget-magenta .card-header {
    background: magenta;
    color: #000;
}

.widget-card.widget-yellow .card-header {
    background: #E0E000;
    color: #000;
}

.widget-card.widget-green .card-header {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    color: #fff;
}

.widget-card.widget-default .card-header {
    background: linear-gradient(135deg, #78909c 0%, #546e7a 100%);
    color: #fff;
}

.widget-card.widget-blue .card-header {
    background: linear-gradient(135deg, #42a5f5 0%, #1976d2 100%);
    color: #fff;
}

.widget-card.widget-orange .card-header {
    background: linear-gradient(135deg, #ffa726 0%, #f57c00 100%);
    color: #fff;
}

/* Widget slider labels */
.widget-card .slider-label {
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0.25rem;
    display: block;
}

.widget-card .slider-value {
    font-weight: 600;
    color: var(--bs-emphasis-color);
}

/* Checkbox personalitzar dins widget */
.widget-card .form-check-personalize {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0.5rem;
}
.widget-card .form-check-personalize.form-switch {
    padding-left: 2.5em;
    min-height: auto;
    overflow: visible;
}

/* Taronja intens per bon contrast en modus clar i fosc */
#confirmationModal .modal-header {
    background-color: #e67e00 !important;
    color: #fff !important;
}
#confirmationModal .btn-warning {
    background-color: #e67e00;
    border-color: #e67e00;
    color: #fff;
}
#confirmationModal .btn-warning:hover {
    background-color: #cc6f00;
    border-color: #cc6f00;
    color: #fff;
}
#confirmWarning,
#warningDiv,
.modal .text-warning:has(#confirmLabel),
#confirmationModal #confirmationMessage {
    color: #e67e00 !important;
    background-color: var(--bs-body-bg);
    border-left: 3px solid #e67e00;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
}

/* ===========================================
   PARAMETERS PAGE LAYOUT
   =========================================== */

/* Contenidor de paràmetres */
.parameters-section {
    margin-bottom: 1.5rem;
}

.parameters-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--bs-emphasis-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Grid de widgets responsive */
.widget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* Tabs millorats per paràmetres */
.parameters-tabs .nav-tabs {
    border-bottom: 2px solid var(--bs-border-color);
    margin-bottom: 0.5rem;
}

.parameters-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--bs-secondary-color);
    font-weight: 500;
    padding: 0.35rem 1rem;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.parameters-tabs .nav-link:hover {
    color: var(--bs-emphasis-color);
    border-bottom-color: var(--bs-border-color);
}

.parameters-tabs .nav-link.active {
    color: var(--bs-primary);
    border-bottom-color: var(--bs-primary);
    background-color: transparent;
}

/* Sliders Bootstrap millorats */
.widget-card .slider.slider-horizontal {
    width: 100%;
    margin: 0.5rem 0;
}

.widget-card .slider-track {
    height: 8px;
    border-radius: 4px;
    background: var(--bs-secondary-bg);
}

.widget-card .slider-selection {
    border-radius: 4px;
}

.widget-card .slider-handle {
    width: 18px;
    height: 18px;
    margin-top: -5px;
}

/* Radio buttons i checkboxes dins widgets */
.widget-card .form-check {
    margin-bottom: 0.35rem;
}

.widget-card .form-check-label {
    font-size: 0.85rem;
}

/* Dark mode adjustments */
[data-bs-theme="dark"] .widget-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

[data-bs-theme="dark"] .widget-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* Widget progress bars */
.widget-card .progress {
    height: 20px;
    position: relative;
}

.widget-card .progress-bar {
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-card .progress .gris {
    font-size: 0.75rem;
    font-weight: 600;
}

/* Widget amb body clar fix (per imatges amb fons blanc) */
.widget-card.widget-body-light .card-body {
    background-color: #ffffff !important;
    color: #333 !important;
}

[data-bs-theme="dark"] .widget-card.widget-body-light .card-body {
    background-color: #ffffff !important;
    color: #333 !important;
}

/* ===========================================
   NAVBAR MÒBIL: slide des de la dreta
   =========================================== */

.navbar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1049;
}

.navbar-overlay.show {
    display: block;
}

@media (max-width: 767.98px) {
    .navbar-collapse {
        position: fixed;
        top: 0;
        right: 0;
        width: 280px;
        height: 100vh;
        background-color: var(--bs-secondary-bg);
        z-index: 1050;
        overflow-y: auto;
        padding: 1rem;
        display: block !important;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    .navbar-collapse.show {
        transform: translateX(0);
    }
}
