/* ===================================================
   Panel de Gestión de Incidencias - Ayto. Isla Cristina
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- Variables --- */
:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-hover: #1e293b;
    --sidebar-active: var(--primary);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* --- LOGIN PAGE --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, #0f172a 50%, #1e3a5f 100%);
    padding: 1rem;
}
.login-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: fadeInUp 0.5s ease;
}
.login-card .logo { width: 80px; margin-bottom: 1rem; }
.login-card h1 { font-size: 1.4rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 0.25rem; }
.login-card .subtitle { color: var(--text-light); font-size: 0.85rem; margin-bottom: 1.5rem; }

/* --- FORMS --- */
.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.35rem; color: var(--text); font-size: 0.85rem; }
.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.85rem;
    background: #fff;
    cursor: pointer;
}
.form-select:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.error-msg { background: #fef2f2; color: var(--danger); padding: 0.6rem 0.85rem; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 1rem; border: 1px solid #fecaca; }
.success-msg { background: #f0fdf4; color: var(--success); padding: 0.6rem 0.85rem; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 1rem; border: 1px solid #bbf7d0; }

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-purple:hover { background: #7c3aed; color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #475569; color: #fff; }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { background: var(--bg); border-color: var(--text-muted); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* --- LAYOUT --- */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}
.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-header img { width: 38px; height: 38px; border-radius: 8px; }
.sidebar-header .brand { font-weight: 600; font-size: 1rem; color: #fff; }
.sidebar-header .brand small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--text-muted); }
.sidebar-nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center;
    padding: 0.7rem 1.25rem;
    color: var(--sidebar-text);
    font-size: 1rem;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: rgba(59,130,246,0.15); color: var(--primary-light); border-left-color: var(--primary-light); font-weight: 500; }
.sidebar-nav .nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; margin-right: 0.65rem; }
.sidebar-nav .nav-section { padding: 1.25rem 1.25rem 0.5rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,0.08); font-size: 0.9rem; }
.sidebar-footer a { color: var(--text-muted); display: flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.sidebar-footer a:hover { color: #fff; }

/* Main Content */
.main-content { flex: 1; margin-left: 250px; padding: 1.5rem 2rem; min-height: 100vh; }
.page-header-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.page-header-bar h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.page-header-bar .breadcrumb { font-size: 0.8rem; color: var(--text-muted); }

/* Mobile toggle */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 0.75rem; left: 0.75rem;
    z-index: 200;
    background: var(--sidebar-bg);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 0.5rem 0.65rem;
    font-size: 1.2rem;
    cursor: pointer;
}

/* --- CARDS --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-body { padding: 1.25rem; }

/* Stats Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    border-left: 4px solid transparent;
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); text-decoration: none; color: inherit; }
.stat-card .stat-icon { font-size: 2rem; width: 3rem; text-align: center; }
.stat-card .stat-info { flex: 1; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-light); font-weight: 500; }
.stat-card.presentada { border-left-color: var(--primary-light); }
.stat-card.presentada .stat-value { color: var(--primary-light); }
.stat-card.tramitandose { border-left-color: var(--warning); }
.stat-card.tramitandose .stat-value { color: var(--warning); }
.stat-card.solucionada { border-left-color: var(--success); }
.stat-card.solucionada .stat-value { color: var(--success); }
.stat-card.derivada { border-left-color: var(--purple); }
.stat-card.derivada .stat-value { color: var(--purple); }
.stat-card.noprocede { border-left-color: var(--danger); }
.stat-card.noprocede .stat-value { color: var(--danger); }
.stat-card.total { border-left-color: var(--text); }
.stat-card.total .stat-value { color: var(--text); }

/* --- TABLES --- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
    background: var(--bg);
    padding: 0.7rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
tbody td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* --- BADGES --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}
.badge-presentada { background: #dbeafe; color: #1e40af; }
.badge-tramitandose { background: #fef3c7; color: #92400e; }
.badge-solucionada { background: #d1fae5; color: #065f46; }
.badge-derivada { background: #ede9fe; color: #5b21b6; }
.badge-noprocede { background: #fee2e2; color: #991b1b; }
.badge-default { background: #f1f5f9; color: #475569; }

/* --- FILTERS BAR --- */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filters-bar .search-input {
    flex: 1;
    min-width: 200px;
    position: relative;
}
.filters-bar .search-input input { padding-left: 2.2rem; }
.filters-bar .search-input .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- DETAIL PAGE --- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-item { padding: 0.75rem 0; }
.detail-item .detail-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 600; margin-bottom: 0.2rem; }
.detail-item .detail-value { font-size: 0.95rem; color: var(--text); word-break: break-word; }
.detail-full { grid-column: 1 / -1; }
.actions-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; padding-top: 1rem; border-top: 1px solid var(--border); margin-top: 1rem; }
.derivar-select { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* --- PAGINATION --- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.35rem; margin-top: 1.25rem; }
.pagination a, .pagination span {
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
}
.pagination a { color: var(--text); background: var(--bg-card); border: 1px solid var(--border); }
.pagination a:hover { background: var(--bg); border-color: var(--primary-light); color: var(--primary); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border: 1px solid var(--primary); }
.pagination .disabled { color: var(--text-muted); pointer-events: none; opacity: 0.5; }

/* --- DERIVADAS MINI GRID --- */
.derivadas-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.75rem; }
.derivada-mini {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.5rem 0.75rem;
    background: #faf5ff;
    border-radius: var(--radius);
    font-size: 0.8rem;
}
.derivada-mini .d-label { color: var(--purple); font-weight: 500; }
.derivada-mini .d-count { font-weight: 700; color: var(--text); }

/* --- EMPTY STATE --- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.95rem; }

/* --- ANIMATIONS --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.4s ease forwards; }

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .mobile-toggle { display: block; }
    .main-content { margin-left: 0; padding: 1rem; padding-top: 3.5rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .page-header-bar { flex-direction: column; align-items: flex-start; }
    .derivadas-detail { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; }
    .filters-bar .search-input { width: 100%; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    html { font-size: 13px; }
}

/* --- OVERLAY (mobile sidebar) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}
.sidebar-overlay.show { display: block; }
