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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary: #475569;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.25);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    background-image: radial-gradient(at 0% 0%, hsla(217,100%,90%,1) 0, transparent 50%), 
                      radial-gradient(at 100% 100%, hsla(217,100%,95%,1) 0, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

.page-shell, .admin-shell, .login-shell {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.6s ease-out forwards;
}

.admin-shell {
    max-width: 1200px;
}

.login-shell {
    max-width: 500px;
    margin-top: 5vh;
}

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

/* Typography */
h1, h2, h3 {
    color: var(--text-main);
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* Panels */
.hero-panel,
.form-panel,
.footer-card,
.login-panel {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    transition: var(--transition);
}

.hero-panel {
    text-align: center;
    background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
    border-top: 6px solid var(--primary);
    padding: 3rem 2rem;
}

.hero-panel:hover {
    box-shadow: var(--shadow-glow);
}

.eyebrow, .section-kicker {
    display: inline-block;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    background: var(--primary-light);
    padding: 0.35rem 1rem;
    border-radius: 9999px;
    box-shadow: var(--shadow-sm);
}

.hero-copy h1 {
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0 auto;
    max-width: 800px;
    padding-bottom: 0.2em;
}

.panel-header, .panel-header-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.panel-header h2, .panel-header-wrap h2 {
    font-size: 1.875rem;
}

.admin-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.panel-badge {
    background-color: var(--primary-light);
    color: var(--primary-hover);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

/* Sections */
.identity-card,
.field-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.identity-card:hover,
.field-section:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
    transform: translateY(-2px);
}

.identity-card {
    background: linear-gradient(to right, #ffffff, var(--primary-light));
    border-left: 4px solid var(--primary);
}

.identity-heading, .section-head {
    margin-bottom: 1.5rem;
}

.identity-heading h3, .section-head h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.identity-heading p, .section-head p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Forms */
.form-grid {
    display: flex;
    flex-direction: column;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.form-row .form-group {
    margin-bottom: 0;
}

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="password"],
select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
    appearance: none;
}

input::placeholder {
    color: #94a3b8;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
    background-color: #ffffff;
}

input[readonly] {
    background-color: #f8fafc;
    color: var(--text-muted);
    cursor: not-allowed;
    border-color: #e2e8f0;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
    cursor: pointer;
}

/* Input with button */
.input-with-button {
    display: flex;
    gap: 0.75rem;
}
.input-with-button input {
    flex: 1;
}

/* Buttons */
button, .btn-link {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#btnBuscarDni {
    padding: 0 1.5rem;
    background-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

#btnBuscarDni:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

#btnBuscarDni:active:not(:disabled) {
    transform: translateY(0);
}

.btn-submit {
    width: 100%;
    padding: 1.25rem;
    font-size: 1.125rem;
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-top: 1rem;
}

.btn-submit:hover:not(:disabled) {
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.btn-link.secondary {
    background-color: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
}
.btn-link.secondary:hover {
    background-color: var(--surface-hover);
    border-color: #cbd5e1;
}

.btn-link.small {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

/* Status Text */
.status-text {
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.5rem;
    min-height: 1.25rem;
}
.status-text.is-loading { color: var(--primary); }
.status-text.is-success { color: #008000 !important; font-weight: bold; } /* Verde Fuerte */
.status-text.is-error { color: #ff0000 !important; } 
.status-text.is-manual { color: #0000FF !important; font-weight: bold; font-size: 1rem; } /* Azul Fuerte */

/* Message box */
#message {
    display: none;
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}
.success {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Footer */
.footer-card {
    text-align: center;
    padding: 2rem;
    background: var(--surface);
}
.footer-title {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}
.footer-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Admin Table overrides */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    margin-top: 1rem;
    -webkit-overflow-scrolling: touch;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}
.admin-table th {
    background-color: #f8fafc;
    color: var(--secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.admin-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.9rem;
    vertical-align: middle;
}
.admin-table tbody tr:hover {
    background-color: var(--surface-hover);
}
.action-inline {
    display: flex;
    gap: 0.5rem;
}
.btn-link.danger {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}
.btn-link.danger:hover {
    background-color: #fca5a5;
    color: #7f1d1d;
}

/* Media Queries */
@media (max-width: 768px) {
    body { padding: 1rem 0.5rem; }
    .hero-panel, .form-panel, .footer-card, .login-panel { padding: 1.5rem; }
    .panel-header, .panel-header-wrap { flex-direction: column; align-items: stretch; text-align: center; }
    .input-with-button { flex-direction: column; }
    #btnBuscarDni { width: 100%; padding: 1rem; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .form-group { margin-bottom: 1rem; }
    .admin-actions { width: 100%; justify-content: center; flex-direction: column; gap: 0.75rem; }
    .admin-actions .btn-link { width: 100%; }
    .panel-badge { align-self: center; margin-bottom: 0.5rem; }
    
    .hero-panel { padding: 2rem 1.5rem; }
    .hero-copy h1 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    h1 { font-size: 1.3rem !important; }
    h2 { font-size: 1.4rem !important; }
    .hero-panel, .form-panel { padding: 1.25rem; }
    .identity-card, .field-section { padding: 1.25rem; }
}