/**
 * Base styles for ECAMonitor3 Frontend
 */

/* CSS Variables for consistent theming */
:root {
    --primary-color: #495057;
    --primary-hover: #343a40;
    --primary-active: #212529;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --border-color: #dee2e6;
    --text-muted: #6c757d;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Base styles */
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: var(--light-color);
    font-size: 0.95rem;
    background: url('https://sdis-malley.ch/wp-content/uploads/2025/06/accueil.jpg') no-repeat center center fixed;
    background-size: cover;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden; /* prevent body scroll, main will scroll */
    overscroll-behavior: none; /* prevent pull-to-reveal chrome on iPad */
    touch-action: manipulation;
}

/* Make central area scrollable only */
main {
    flex: 1 1 auto;
    min-height: 0; /* allow flex item to shrink for overflow */
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

/* When Bootstrap modal is open, prevent underlying scrollable area from capturing touches (iOS) */
body.modal-open main {
    overflow: hidden;
}

/* Small devices: minimize horizontal padding for all pages (keep navbar intact) */
@media (max-width: 576px) {
    /* Main wrapper often carries utility classes that add px; zero them out */
    body:not(.login-page) main.px-3,
    body:not(.login-page) main.px-4,
    body:not(.login-page) main.px-3.py-4,
    body:not(.login-page) main.px-4.py-4 {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }
    /* Any fluid container inside the main area */
    body:not(.login-page) main > .container-fluid {
        padding-left: 0px !important;
        padding-right: 0px !important;
    }
}

/* Modern navbar styling */
.navbar {
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, #212529 0%, #343a40 100%) !important;
    padding-top: 6px;
    padding-bottom: 6px;
}

.navbar-brand {
    font-size: 1.4rem;
    letter-spacing: -0.025em;
    padding-top: 0px;
    padding-bottom: 0px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border-radius: 8px;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.brand-text {
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #e9ecef 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-link {
    transition: all 0.2s ease-in-out;
    font-weight: 500;
    position: relative;
    padding-top: .25rem;
    padding-bottom: .25rem;
}

/* Align menu text to the right on smaller devices */
@media (max-width: 576px) {
    .navbar-nav .nav-link {
        justify-content: flex-end;
    }
    .navbar-nav .nav-link span {
        text-align: right;
    }
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
}

.user-avatar {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-size: 0.9rem;
}

.user-name {
    font-weight: 500;
}

.dropdown-menu {
    border-radius: 12px;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
}

.dropdown-item {
    border-radius: 8px;
    margin: 0 0.5rem;
    transition: all 0.2s ease-in-out;
}

.dropdown-item:hover {
    background-color: var(--light-color);
    transform: translateX(4px);
}

/* Modern alert styling */
.alert {
    border-radius: 12px;
    border: none;
    font-weight: 500;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
}

/* Modern button styling */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    border-width: 1px;
    position: relative;
    overflow: hidden;
}

/* Consistent small gap between adjacent buttons in toolbars */
.btn + .btn { margin-left: .5rem; }
.btn-group .btn + .btn { margin-left: .5rem; }

/* Override Bootstrap's negative margins in grouped buttons for our toolbars */
.users-toolbar .btn-group > .btn + .btn,
.equipage-toolbar .btn-group > .btn + .btn,
.interventions-toolbar .btn-group > .btn + .btn {
    margin-left: .5rem !important;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-active) 100%);
    border-color: var(--primary-hover);
}

/* Modern card styling */
.card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease-in-out;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

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

.card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
}

/* Modern footer styling */
footer {
    margin-top: auto;
    background: linear-gradient(135deg, #212529 0%, #343a40 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0;
    padding-bottom: 0;
}

footer p {
    font-size: 0.875rem;
    margin-bottom: 0;
    color: #ffffff;
}

@media (max-width: 576px) {
  footer p { font-size: 0.75rem; }
  footer .row { text-align: center; }
  footer .col-md-6 { text-align: center !important; }
}

footer i {
    color: #f8f9fa;
}

/* Websocket indicator (shared) */
.ws-indicator { display:inline-flex; align-items:center; gap:.35rem; color:#6c757d; }
.ws-dot { width:10px; height:10px; border-radius:50%; background:#dc3545; box-shadow:0 0 0 2px rgba(220,53,69,.15); }
.ws-connected .ws-dot { background:#28a745; box-shadow:0 0 0 2px rgba(40,167,69,.15); }
.ws-connected { color:#198754; }
/* brief pulse when WS message received */
.ws-indicator.ws-pulse .ws-dot { box-shadow:0 0 0 6px rgba(25, 135, 84, .25); transition: box-shadow .25s ease; }

/* Page loading overlay */
#pageLoading {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(2px);
    z-index: 2000;
    pointer-events: none; /* prevent accidental blocking when hidden */
}
#pageLoading.show { display: flex; pointer-events: all; }
#pageLoading .loader {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    background: rgba(248,249,250,.95);
    border: 1px solid rgba(0,0,0,.1);
    border-radius: .75rem;
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15);
}
#pageLoading .label {
    color: #495057;
    font-weight: 600;
}

/* (dashboard modules and login-page styles are defined elsewhere) */

/* Ensure Bootstrap modal overlays correctly above other layers on iOS */
.modal-backdrop { z-index: 2050; }
.modal { z-index: 2060; }

