/* CSS custom properties */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #10b981;
    --accent: #22d3ee;
    --dark: #1e293b;
    --darker: #0f172a;
    --light: #f8fafc;
    --gray: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: #e2e8f0;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

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

/* Document body */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    color: #334155;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

/* Central container */
.container {
    margin: 0 auto;
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
}

/* Page‑specific container widths */
.form-page .container {
    max-width: 1000px;
}

.buscar-page .container {
    max-width: 1200px;
}

/* Header and typography */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.logo {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 10px;
}

h1 {
    color: var(--dark);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--gray);
    font-size: 16px;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    font-size: 15px;
    display: flex;
    align-items: flex-start;
}

.alert i {
    margin-right: 12px;
    font-size: 20px;
    flex-shrink: 0;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

/* Brand image */
.brand-img {
    width: 140px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 16px 28px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(37, 99, 235, 0.25);
}

.btn i {
    margin-right: 8px;
}

/* Outline and success variants */
.btn-outline {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

/* Layout helpers */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 18px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    display: flex;
    align-items: center;
}

.section-title i {
    margin-right: 10px;
    color: var(--primary);
}

.form-group {
    margin-bottom: 18px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

/* Inputs and selects */
input,
select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    background: white;
    color: #1f2937;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input.uppercase {
    text-transform: uppercase;
}

/* Miscellaneous helpers */
.full-width {
    grid-column: 1 / -1;
}

.required::after {
    content: " *";
    color: var(--danger);
}

.help-text {
    font-size: 13px;
    color: var(--gray);
    margin-top: 6px;
}

/* File preview */
.preview-container {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 10px;
    border: 2px solid var(--primary);
    margin-top: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.file-info {
    font-size: 13px;
    color: var(--gray);
    margin-top: 8px;
    text-align: center;
    padding: 4px 8px;
    background: #f8fafc;
    border-radius: 6px;
}

.upload-section {
    background: #f0f9ff;
    padding: 24px;
    border-radius: 12px;
    border: 2px dashed #bae6fd;
    margin-top: 24px;
}

.drive-links {
    margin-top: 16px;
    padding: 16px;
    background: #f0f9ff;
    border-radius: 10px;
    border-left: 4px solid var(--primary);
}

.drive-link {
    display: flex;
    align-items: center;
    margin: 8px 0;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.drive-link:hover {
    color: var(--primary-dark);
}

.drive-link i {
    margin-right: 8px;
}

/* Loading overlays */
.overlay-loader {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loader-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .12);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
}

/* Generic spinner */
.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(226, 232, 240, 1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

.loader-text {
    color: #334155;
    font-weight: 600;
    margin-top: 16px;
    text-align: center;
    font-size: 18px;
}

/* Phone input grouping */
.phone-group {
    display: flex;
    gap: 12px;
}

.phone-code {
    flex: 0 0 100px;
}

.phone-number {
    flex: 1;
}

.file-input-container {
    position: relative;
}

.file-input-container input[type="file"] {
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
}

.error-message {
    color: var(--danger);
    font-size: 13px;
    margin-top: 5px;
    display: none;
}

/* Actions & tables (used on search page) */
.actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.table-wrap {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #64748b;
    background: #f1f5f9;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

tbody tr:nth-child(even) {
    background: #f8fafc;
}

a.link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

a.link:hover {
    text-decoration: underline;
}

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pager .info {
    font-size: 14px;
    color: var(--gray);
}

.pager .controls {
    display: flex;
    gap: 6px;
}

.page-btn {
    border: 1px solid var(--border);
    background: white;
    color: var(--dark);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s;
}

.page-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-btn[aria-disabled="true"] {
    opacity: .45;
    cursor: not-allowed;
}

.page-num {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: white;
    color: var(--dark);
    display: inline-flex;
    align-items: center;
}

/* Thumbnails */
.thumb {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

.thumb-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.no-file {
    color: var(--gray);
    font-size: 12px;
}

/* Footer */
.footer {
    margin-top: 28px;
    text-align: center;
    color: var(--gray);
}

.footer .logo {
    font-size: 1.6rem;
    color: var(--primary);
}

/* Country flags and option spacing */
.country-flag {
    margin-right: 8px;
    width: 20px;
    height: 15px;
    display: inline-block;
    vertical-align: middle;
    background: #eee;
    border: 1px solid #ddd;
}

select option {
    padding: 10px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .container {
        padding: 24px;
    }
    .phone-group {
        flex-direction: column;
    }
}