/* ===================================
   ESTILO BASE - Mobile First v2.0
   Hospital Clínico Viedma
   =================================== */

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--color-texto);
    background: var(--color-fondo);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--color-primario);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover { color: var(--color-secundario); }

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Tipografía */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-secundario);
}

h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.3rem; margin-bottom: 0.8rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.6rem; }

p {
    margin-bottom: 0.8rem;
    color: var(--color-texto-claro);
}

/* Contenedor */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Tarjetas */
.card {
    background: #ffffff;
    border-radius: var(--borde-radius);
    box-shadow: var(--sombra);
    padding: 16px;
    margin-bottom: 16px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--sombra-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--color-fondo);
    flex-wrap: wrap;
    gap: 8px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-secundario);
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    min-height: 44px;
    min-width: 44px;
    border: none;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    line-height: 1.4;
    text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--color-primario), var(--color-secundario));
    color: #fff;
}
.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(0,119,182,0.4);
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
}
.btn-success:hover {
    box-shadow: 0 4px 15px rgba(46,204,113,0.4);
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: #fff;
}
.btn-warning:hover {
    box-shadow: 0 4px 15px rgba(243,156,18,0.4);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
}
.btn-danger:hover {
    box-shadow: 0 4px 15px rgba(231,76,60,0.4);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--color-primario);
    color: var(--color-primario);
}
.btn-outline:hover {
    background: var(--color-primario);
    color: #fff;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
    min-height: 36px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.1rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Formularios */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-texto);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    min-height: 44px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    color: var(--color-texto);
    background: #fff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primario);
    box-shadow: 0 0 0 3px rgba(0,119,182,0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    font-size: 16px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23333' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-bien { background: rgba(46,204,113,0.15); color: #27ae60; }
.badge-neutro { background: rgba(243,156,18,0.15); color: #e67e22; }
.badge-malo { background: rgba(231,76,60,0.15); color: #c0392b; }
.badge-urgente {
    background: #ffe0e0;
    color: #c0392b;
    animation: pulse-urgente 2s ease-in-out infinite;
}

@keyframes pulse-urgente {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Tablas */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--borde-radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table thead {
    background: linear-gradient(135deg, var(--color-primario), var(--color-secundario));
    color: #fff;
}

.table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.table tbody tr { transition: background 0.2s ease; }
.table tbody tr:hover { background: rgba(0,119,182,0.04); }
.table tbody tr.urgente { background: #ffe0e0 !important; }

/* Alertas */
.alert {
    padding: 14px 16px;
    border-radius: var(--borde-radius);
    margin-bottom: 16px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-info { background: rgba(0,119,182,0.1); color: var(--color-primario); border-left: 4px solid var(--color-primario); }
.alert-success { background: rgba(46,204,113,0.1); color: #27ae60; border-left: 4px solid #27ae60; }
.alert-danger { background: rgba(231,76,60,0.1); color: #c0392b; border-left: 4px solid #e74c3c; }
.alert-warning { background: rgba(243,156,18,0.1); color: #e67e22; border-left: 4px solid #f39c12; }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }

/* Flex */
.flex { display: flex; gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Textos */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-small { font-size: 0.85rem; }
.text-muted { color: var(--color-texto-claro); }
.text-success { color: var(--color-exito); }
.text-danger { color: var(--color-peligro); }
.text-warning { color: var(--color-neutro); }
.text-primary { color: var(--color-primario); }

/* Márgenes */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.p-3 { padding: 24px; }

.w-100 { width: 100%; }
.d-none { display: none !important; }

/* Animaciones */
.fade-in { animation: fadeIn 0.4s ease forwards; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: #fff;
    border-radius: var(--borde-radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 12px; right: 12px;
    width: 36px; height: 36px;
    border: none;
    background: var(--color-fondo);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--color-texto-claro);
}

/* Loader */
.loader {
    display: inline-block;
    width: 24px; height: 24px;
    border: 3px solid var(--color-fondo);
    border-top-color: var(--color-primario);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-fondo); }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }
