/* ============================================================
   DASE - Sistema de Solicitudes
   CSS Nativo - Mobile First
   ============================================================ */

/* === RESET & BASE === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --success: #0f9d58;
    --warning: #f4b400;
    --danger: #d93025;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f4;
    --gray-200: #e8eaed;
    --gray-300: #dadce0;
    --gray-500: #9aa0a6;
    --gray-700: #5f6368;
    --gray-900: #202124;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 8px;
    --radius-sm: 4px;
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* === NAVBAR === */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 8px;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary) !important;
    text-decoration: none !important;
    white-space: nowrap;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    color: var(--gray-700);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
    flex: 1;
}

.nav-menu li a {
    display: block;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    font-size: 0.9rem;
    transition: background var(--transition);
}

.nav-menu li a:hover {
    background: var(--gray-100);
    text-decoration: none;
}

.nav-user {
    font-size: 0.85rem;
    color: var(--gray-500);
    white-space: nowrap;
    margin-left: auto;
}

/* === MAIN CONTAINER === */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* === ALERTS === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: #e6f4ea;
    color: #1e7e34;
    border: 1px solid #b7e1cd;
}

.alert-error {
    background: #fce8e6;
    color: #c5221f;
    border: 1px solid #f5c6cb;
}

/* === CARDS === */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--gray-900);
}

/* === DASHBOARD === */
.dashboard-welcome {
    margin-bottom: 24px;
}

.dashboard-welcome h1 {
    font-size: 1.5rem;
    color: var(--gray-900);
}

.welcome-role {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card-total { border-left: 4px solid var(--primary); }
.card-pending { border-left: 4px solid var(--danger); }
.card-solved { border-left: 4px solid var(--success); }

.card-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.card-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.card-label {
    display: block;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.dashboard-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none !important;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: var(--white) !important;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--white);
    color: var(--gray-700) !important;
    border-color: var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-100);
}

.btn-success {
    background: var(--success);
    color: var(--white) !important;
}

.btn-warning {
    background: var(--warning);
    color: var(--gray-900) !important;
}

.btn-danger {
    background: var(--danger);
    color: var(--white) !important;
}

.btn-danger:hover {
    background: #b31412;
}

.btn-link {
    background: none;
    color: var(--gray-500) !important;
    border: none;
    padding: 10px 0;
}

.btn-link:hover {
    color: var(--gray-700) !important;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* === FORMS === */
.form-container {
    max-width: 640px;
    margin: 0 auto;
}

.form-container h1 {
    font-size: 1.3rem;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--gray-700);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition);
    background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-help {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 4px;
    display: block;
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.input-edit {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    min-width: 180px;
}

.input-edit:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

/* === LOGIN === */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
    background: linear-gradient(135deg, #1a73e8 0%, #1557b0 100%);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--gray-900);
}

.login-header p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.login-form .form-group {
    margin-bottom: 20px;
}

/* === TABLES === */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table th {
    background: var(--gray-100);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-700);
    text-align: left;
    padding: 12px 16px;
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    font-size: 0.9rem;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table .actions {
    white-space: nowrap;
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-pending {
    background: #fce8e6;
    color: #c5221f;
}

.status-solved {
    background: #e6f4ea;
    color: #1e7e34;
}

.badge-rol {
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 0.75rem;
    font-weight: 600;
}

/* === FILTROS GRID === */
.filtros-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.filtros-form {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

/* === PAGE HEADER === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.3rem;
}

/* === TABS === */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    font-size: 0.9rem;
    color: var(--gray-500) !important;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none !important;
}

.tab:hover {
    color: var(--gray-700) !important;
    background: var(--gray-50);
}

.tab.active {
    color: var(--primary) !important;
    border-bottom-color: var(--primary);
    font-weight: 500;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--gray-500);
}

.empty-state p {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

/* === MODAL === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    background: var(--white);
}

.modal-header h2 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-body {
    padding: 20px;
}

.detalle-grid p {
    margin-bottom: 8px;
}

.detalle-texto {
    background: var(--gray-50);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    white-space: pre-wrap;
    font-size: 0.9rem;
}

/* === IMAGENES GRID === */
.imagenes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.imagen-item {
    position: relative;
    cursor: pointer;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid var(--gray-200);
}

.imagen-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
    transition: transform var(--transition);
}

.imagen-item:hover img {
    transform: scale(1.05);
}

.imagen-item span {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.75rem;
}

/* === PREVIEW GRID === */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.preview-grid img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

/* === ERROR LIST === */
.error-list {
    list-style: none;
    padding: 0;
}

.error-list li {
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--danger);
    border-bottom: 1px solid var(--gray-100);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 8px 16px;
        border-bottom: 1px solid var(--gray-200);
        box-shadow: var(--shadow);
    }

    .nav-menu.open {
        display: flex;
    }

    .nav-user {
        display: none;
    }

    .dashboard-cards {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .table thead {
        display: none;
    }

    .table tbody tr {
        display: block;
        padding: 12px;
        border: 1px solid var(--gray-200);
        margin-bottom: 8px;
        border-radius: var(--radius);
    }

    .table tbody tr td {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        border: none;
        font-size: 0.85rem;
    }

    .table tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-500);
        font-size: 0.8rem;
    }

    .table tbody tr td:not(:last-child) {
        border-bottom: 1px solid var(--gray-100);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-content {
        margin: 8px;
        max-height: 85vh;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 16px 12px;
    }

    .card {
        padding: 16px;
    }

    .login-card {
        padding: 24px 20px;
    }
}