/* ============================================
   TEMA SAV - Modern Stylesheet
   Brand color: #006AB3
   ============================================ */

:root {
    --tema-primary: #006AB3;
    --tema-primary-dark: #005494;
    --tema-primary-light: #e8f4fc;
    --tema-primary-hover: #0080d6;
    --tema-accent: #00b4d8;
    --tema-sidebar-bg: #0d1b2a;
    --tema-sidebar-hover: #1b2d44;
    --tema-sidebar-active: #006AB3;
    --tema-sidebar-text: #a8c0d8;
    --tema-sidebar-heading: #5a7a96;
    --tema-sidebar-width: 260px;
    --tema-success: #2ecc71;
    --tema-danger: #e74c3c;
    --tema-warning: #f39c12;
    --tema-gray-100: #f8f9fa;
    --tema-gray-200: #e9ecef;
    --tema-gray-300: #dee2e6;
    --tema-gray-600: #6c757d;
    --tema-section-header-bg: #006AB3;
    --tema-section-header-text: #ffffff;
    --tema-transition: 0.2s ease;
}

/* ---- Global ---- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f0f2f5;
    color: #2d3436;
    font-size: 0.9rem;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--tema-sidebar-width);
    height: 100vh;
    background: var(--tema-sidebar-bg);
    color: var(--tema-sidebar-text);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: transform var(--tema-transition);
    scrollbar-width: thin;
    scrollbar-color: var(--tema-sidebar-hover) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: var(--tema-sidebar-hover);
    border-radius: 3px;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: center;
}

.sidebar-brand img {
    max-width: 140px;
    height: auto;
    filter: brightness(0) invert(1);
}

.sidebar-nav {
    padding: 0.5rem 0;
}

.sidebar-section {
    padding: 0 0.75rem;
    margin-bottom: 0.25rem;
}

.sidebar-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tema-sidebar-heading);
    padding: 0.75rem 0.75rem 0.35rem;
    margin: 0;
    user-select: none;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.45rem 0.75rem;
    color: var(--tema-sidebar-text);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.82rem;
    transition: all var(--tema-transition);
    gap: 0.6rem;
    margin-bottom: 1px;
}

.sidebar-link:hover {
    background: var(--tema-sidebar-hover);
    color: #ffffff;
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--tema-sidebar-active);
    color: #ffffff;
    font-weight: 500;
}

.sidebar-link i {
    width: 18px;
    text-align: center;
    font-size: 0.82rem;
    opacity: 0.75;
    flex-shrink: 0;
}

.sidebar-link:hover i,
.sidebar-link.active i {
    opacity: 1;
}

.sidebar-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin: 0.5rem 1rem;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: auto;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--tema-sidebar-text);
    font-size: 0.8rem;
}

.sidebar-user i {
    font-size: 1.1rem;
    opacity: 0.6;
}

.sidebar-user-name {
    font-weight: 500;
    color: #fff;
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--tema-sidebar-width);
    min-height: 100vh;
    padding: 1.5rem 2rem;
    transition: margin-left var(--tema-transition);
}

/* ---- Login Page (no sidebar) ---- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #006AB3 0%, #004a7c 50%, #0d1b2a 100%);
}

.login-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-card .logo-container {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .logo-container img {
    max-width: 160px;
    height: auto;
}

.login-card h5 {
    text-align: center;
    color: var(--tema-gray-600);
    font-weight: 400;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #2d3436;
    margin: 0;
}

.page-breadcrumb {
    font-size: 0.82rem;
    color: var(--tema-gray-600);
}

/* ---- Cards & Sections ---- */
.tema-card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.25rem;
    border: 1px solid var(--tema-gray-200);
    overflow: hidden;
}

.tema-card-header {
    background: var(--tema-section-header-bg);
    color: var(--tema-section-header-text);
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tema-card-header i {
    opacity: 0.85;
}

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

/* ---- Detail/Edit View ---- */
.detail-row {
    display: flex;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--tema-gray-100);
    align-items: center;
    min-height: 36px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    flex: 0 0 180px;
    color: var(--tema-gray-600);
    font-size: 0.82rem;
    padding-right: 0.75rem;
}

.detail-value {
    flex: 1;
    font-weight: 500;
    color: #2d3436;
    font-size: 0.88rem;
}

.detail-value a {
    color: var(--tema-primary);
    text-decoration: none;
}

.detail-value a:hover {
    text-decoration: underline;
}

/* Edit mode field visibility */
.view-mode .edit-field { display: none; }
.view-mode .view-field { display: inline; }
.edit-mode .edit-field { display: inline; }
.edit-mode .view-field { display: none; }

.edit-field .form-control,
.edit-field .form-select {
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    height: auto;
}

/* ---- Warranty Badge ---- */
.badge-warranty {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-weight: 600;
}

.badge-warranty.under-warranty {
    background-color: #d4edda;
    color: #155724;
}

.badge-warranty.expired-warranty {
    background-color: #f8d7da;
    color: #721c24;
}

.badge-warranty.na-warranty {
    background-color: var(--tema-gray-200);
    color: var(--tema-gray-600);
}

/* ---- Toolbar ---- */
.page-toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.page-toolbar .btn {
    font-size: 0.82rem;
    padding: 0.4rem 0.85rem;
}

/* ---- Tables ---- */
.tema-table {
    width: 100%;
    font-size: 0.85rem;
}

.tema-table thead th {
    background: var(--tema-primary);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.6rem 0.75rem;
    border: none;
    white-space: nowrap;
}

.tema-table tbody tr {
    cursor: pointer;
    transition: background-color var(--tema-transition);
}

.tema-table tbody tr:hover {
    background-color: var(--tema-primary-light) !important;
}

.tema-table tbody td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--tema-gray-200);
    vertical-align: middle;
}

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

/* ---- Search Form ---- */
.search-section {
    margin-bottom: 1rem;
}

.search-section .tema-card-header {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
}

/* ---- Dashboard Cards ---- */
.dashboard-card {
    background: #ffffff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--tema-gray-200);
    text-align: center;
    transition: transform var(--tema-transition), box-shadow var(--tema-transition);
    height: 100%;
}

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

.dashboard-card-icon {
    font-size: 2rem;
    color: var(--tema-primary);
    margin-bottom: 0.75rem;
}

.dashboard-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #2d3436;
    margin-bottom: 0.25rem;
}

.dashboard-card-text {
    font-size: 0.82rem;
    color: var(--tema-gray-600);
}

/* ---- Infinite Scroll ---- */
.infinite-scroll-loader {
    text-align: center;
    padding: 1.5rem;
    color: var(--tema-gray-600);
    display: none;
}

.infinite-scroll-loader.active {
    display: block;
}

.infinite-scroll-end {
    text-align: center;
    padding: 1rem;
    color: var(--tema-gray-600);
    font-size: 0.82rem;
    font-style: italic;
    display: none;
}

.infinite-scroll-end.active {
    display: block;
}

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080;
}

/* ---- Buttons ---- */
.btn-tema {
    background-color: var(--tema-primary);
    border-color: var(--tema-primary);
    color: #ffffff;
}

.btn-tema:hover {
    background-color: var(--tema-primary-dark);
    border-color: var(--tema-primary-dark);
    color: #ffffff;
}

.btn-tema-outline {
    border-color: var(--tema-primary);
    color: var(--tema-primary);
    background: transparent;
}

.btn-tema-outline:hover {
    background-color: var(--tema-primary);
    color: #ffffff;
}

/* ---- Pagination (fallback) ---- */
.pagination .page-link {
    color: var(--tema-primary);
}

.pagination .page-item.active .page-link {
    background-color: var(--tema-primary);
    border-color: var(--tema-primary);
}

/* ---- Form overrides ---- */
.form-control:focus,
.form-select:focus {
    border-color: var(--tema-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 106, 179, 0.15);
}

/* ---- Result count ---- */
.result-count {
    font-size: 0.85rem;
    color: var(--tema-gray-600);
    margin-bottom: 1rem;
}

.result-count strong {
    color: var(--tema-primary);
    font-weight: 700;
}

/* ---- Legacy compat: old pages inside new layout ---- */
.main-content table[bordercolor="#666699"] tr[bgcolor="#666699"] td {
    background: var(--tema-primary) !important;
}

.main-content table[bordercolor="#666699"] tr[bgcolor="#666699"] font[color="#00FFFF"] {
    color: #ffffff !important;
}

.main-content input.bouton,
.main-content input.BOUTON {
    font-family: inherit;
    font-size: 0.82rem;
    padding: 0.35rem 0.75rem;
    background: #ffffff;
    border: 1px solid var(--tema-gray-300);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--tema-transition);
    color: #2d3436;
}

.main-content input.bouton:hover,
.main-content input.BOUTON:hover {
    background: var(--tema-primary-light);
    border-color: var(--tema-primary);
}

.main-content input.TEXT,
.main-content input.TEXTLOCK,
.main-content input.TEXT_BOLD {
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--tema-gray-300);
    border-radius: 4px;
    width: 200px;
}

.main-content input.TEXT:focus {
    border-color: var(--tema-primary);
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 106, 179, 0.15);
}

.main-content select {
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--tema-gray-300);
    border-radius: 4px;
    width: 200px;
}

.main-content textarea {
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--tema-gray-300);
    border-radius: 4px;
}

/* ---- Navigation record buttons ---- */
.record-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0;
}

/* ---- Print: hide sidebar ---- */
@media print {
    .sidebar { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
}
