/* ============================================
   SAT Mantenimientos - Styles
   ============================================ */

:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #3b82f6;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #0ea5e9;
    --muted: #6b7280;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --radius: 0.75rem;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand i { color: var(--primary-light); font-size: 1.4rem; }

.btn-close-sidebar {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.2rem;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-item:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}

.sidebar-nav .nav-item.active {
    color: #fff;
    background: rgba(59,130,246,0.15);
    border-left-color: var(--sidebar-active);
}

.sidebar-nav .nav-item i { font-size: 1.15rem; width: 1.4rem; text-align: center; }

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

.user-info { display: flex; align-items: center; gap: 0.75rem; }
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 0.85rem;
    flex-shrink: 0;
}
.user-details { overflow: hidden; }
.user-name { display: block; color: #fff; font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 0.75rem; color: var(--sidebar-text); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin 0.3s ease;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.btn-menu {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
    padding: 0.25rem;
}

.search-global {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.search-global i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-global input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}

.search-global input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1050;
    margin-top: 0.25rem;
}

.search-results.active { display: block; }

.search-result-item {
    padding: 0.625rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.search-result-item:hover { background: var(--bg); }
.search-result-item:last-child { border-bottom: none; }

.search-result-item .result-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.search-result-item .result-text small { color: var(--text-light); }

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }

.btn-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    color: var(--text-light);
    text-decoration: none;
    transition: background 0.15s;
    font-size: 1.15rem;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

.notification-badge {
    position: absolute;
    top: 4px; right: 4px;
    width: 18px; height: 18px;
    background: var(--danger);
    color: #fff;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* Page content */
.page-content { padding: 1.5rem; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.breadcrumb {
    font-size: 0.8rem;
    margin: 0.25rem 0 0;
    padding: 0;
    background: none;
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    background: none;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: var(--text);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--text);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.red { background: #fef2f2; color: var(--danger); }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-icon.yellow { background: #fefce8; color: #ca8a04; }
.stat-icon.green { background: #f0fdf4; color: var(--success); }
.stat-icon.blue { background: #eff6ff; color: var(--primary-light); }
.stat-icon.gray { background: #f8fafc; color: var(--muted); }

.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-light); margin-top: 0.125rem; }

/* Tables */
.table-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-container .table {
    margin: 0;
    font-size: 0.875rem;
}

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    border-bottom-width: 2px;
    white-space: nowrap;
    padding: 0.75rem 1rem;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.table tbody tr:hover { background: #f8fafc; }

/* Badges */
.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-active, .badge-operative { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #f1f5f9; color: #64748b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-urgent, .badge-overdue { background: #fef2f2; color: #dc2626; }
.badge-in-progress { background: #dbeafe; color: #1e40af; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }
.badge-broken { background: #fef2f2; color: #dc2626; }

/* Priority badges */
.priority-low { color: var(--info); }
.priority-normal { color: var(--text); }
.priority-high { color: #ea580c; }
.priority-urgent { color: var(--danger); font-weight: 700; }

/* Buttons */
.btn { border-radius: 0.5rem; font-weight: 500; font-size: 0.875rem; padding: 0.5rem 1rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); }

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    transition: all 0.15s;
    cursor: pointer;
}
.btn-action:hover { background: var(--bg); color: var(--text); }
.btn-action.btn-call { color: var(--success); border-color: #bbf7d0; }
.btn-action.btn-call:hover { background: #f0fdf4; }
.btn-action.btn-whatsapp { color: #25d366; border-color: #bbf7d0; }
.btn-action.btn-whatsapp:hover { background: #f0fdf4; }
.btn-action.btn-email { color: var(--primary-light); border-color: #bfdbfe; }
.btn-action.btn-email:hover { background: #eff6ff; }
.btn-action.btn-location { color: #ea580c; border-color: #fed7aa; }
.btn-action.btn-location:hover { background: #fff7ed; }

/* Forms */
.form-label { font-weight: 600; font-size: 0.8rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.025em; margin-bottom: 0.375rem; }
.form-control, .form-select {
    border-radius: 0.5rem;
    border-color: var(--border);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.form-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-section-title i { color: var(--primary-light); }

/* Tabs */
.nav-tabs-custom {
    border-bottom: 2px solid var(--border);
    gap: 0;
}

.nav-tabs-custom .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-light);
    transition: all 0.15s;
}

.nav-tabs-custom .nav-link:hover { color: var(--primary); }
.nav-tabs-custom .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Filters */
.filters-bar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.filters-bar .row { --bs-gutter-x: 0.75rem; --bs-gutter-y: 0.5rem; }

/* Timeline / History */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

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

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.625rem;
    top: 0.375rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 2px solid var(--card-bg);
}

.timeline-date { font-size: 0.75rem; color: var(--text-light); font-weight: 600; }
.timeline-title { font-weight: 600; font-size: 0.9rem; }
.timeline-desc { font-size: 0.8rem; color: var(--text-light); margin-top: 0.25rem; }

/* Maintenance due badge */
.due-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.due-badge.overdue { background: #fef2f2; color: #dc2626; }
.due-badge.due-soon { background: #fff7ed; color: #ea580c; }
.due-badge.upcoming { background: #fefce8; color: #ca8a04; }
.due-badge.ok { background: #f0fdf4; color: #15803d; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-state p { font-size: 0.9rem; }

/* Mobile technician */
.tech-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.tech-card-time {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.tech-card-type {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
}

.tech-card-client {
    font-size: 1rem;
    font-weight: 600;
    margin: 0.25rem 0;
}

.tech-card-address {
    font-size: 0.85rem;
    color: var(--text-light);
}

.tech-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
}

.tech-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
}

.tech-action-btn i { font-size: 1.25rem; }
.tech-action-btn.btn-start { background: var(--success); color: #fff; border-color: var(--success); }

/* Signature pad area */
.signature-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    min-height: 200px;
    background: #fff;
    cursor: crosshair;
    touch-action: none;
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0; }
    .btn-menu { display: block; }
    .page-content { padding: 1rem; }
}

@media (max-width: 575.98px) {
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header .btn { width: 100%; }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.25rem; }
    .topbar { padding: 0 0.75rem; }
    .search-global { max-width: none; }
    .table-container { overflow-x: auto; }
}

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