/* ==============================================
   RESET
   ============================================== */

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

/* ==============================================
   BASE BODY
   ============================================== */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0A2341 0%, #163357 50%, #1e4a73 100%);
    min-height: 100vh;
    color: #333;
}

body.page-index {
    display: flex;
    flex-direction: column;
}

body.page-busqueda {
    background: #f8fafc;
}

body.page-detalle {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* ==============================================
   HEADER
   ============================================== */

.header {
    background: white;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

body.page-index .header {
    justify-content: center;
    position: static;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.logo {
    background: white;
    color: #0A2341;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.2rem;
}

.logo img {
    height: 48px;
    width: auto;
    display: block;
}

.header-text {
    text-transform: uppercase;
}

.header-text h1 {
    font-size: 1.2rem;
    font-weight: bold;
    color: #0A2341;
}

.header-text p {
    font-size: 1rem;
    color: #666;
}

body.page-index .header-text {
    text-align: center;
}

body.page-index .header-text h1 {
    font-size: 1.5rem;
}

body.page-index .header-text p {
    font-size: 1.2rem;
}

/* ==============================================
   CONTAINER
   ============================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

body.page-index .container {
    flex: 1;
}

body.page-resultados .container {
    max-width: 1400px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

body.page-detalle .container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

/* ==============================================
   BUTTONS
   ============================================== */

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-block;
}

.btn-primary {
    background: #0A2341;
    color: white;
}

.btn-primary:hover {
    background: #163357;
}

.btn-secondary {
    background: #e2e8f0;
    color: #64748b;
}

.btn-secondary:hover {
    background: #cbd5e1;
    color: #475569;
}

.back-btn {
    background: #e2e8f0;
    color: #64748b;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #cbd5e1;
    color: #475569;
}

/* Botones grandes (formularios y tarjetas de servicio) */
body.page-index .btn,
body.page-busqueda .btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
}

body.page-index .btn {
    box-shadow: 0 2px 8px rgba(10, 35, 65, 0.2);
    margin-top: auto;
}

body.page-index .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(10, 35, 65, 0.3);
}

body.page-busqueda .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

body.page-busqueda .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(10, 35, 65, 0.3);
}

/* ==============================================
   SHARED COMPONENTS
   ============================================== */

.cbr-info-notice {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-left: 4px solid #f39c12;
    border-radius: 6px;
    padding: 16px 20px;
    margin: 20px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cbr-info-notice__icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

.cbr-info-notice__content {
    flex: 1;
}

.cbr-info-notice__text {
    color: #856404;
    font-size: 18px;
    line-height: 1.5;
    margin: 0;
}

.highlight {
    font-weight: 600;
    color: #b8860b;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid #fcc;
}

body.page-detalle .error-message {
    text-align: center;
}

/* ==============================================
   PAGE: INDEX
   ============================================== */

.admin-link {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(10, 35, 65, 0.9);
    backdrop-filter: blur(10px);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.admin-link:hover {
    background: #0A2341;
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(10, 35, 65, 0.3);
}

.main-title {
    text-align: center;
    color: white;
    margin-bottom: 3rem;
}

.main-title h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.main-title p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.service-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.service-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    border-color: #0A2341;
}

.service-icon {
    width: 80px;
    height: 80px;
    background: #0A2341;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
    color: white;
    box-shadow: 0 4px 16px rgba(10, 35, 65, 0.3);
}

.service-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #0A2341;
}

.service-card p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    flex: 1;
}

.footer {
    background: rgba(10, 35, 65, 0.95);
    backdrop-filter: blur(10px);
    text-align: center;
    padding: 2rem;
    color: white;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==============================================
   PAGE: BUSQUEDA
   ============================================== */

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 2rem;
    color: #0A2341;
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: #666;
    font-size: 1.1rem;
    line-height: 1.6;
    border-left: 4px solid #0A2341;
    padding-left: 1rem;
}

.search-form {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

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

.form-group {
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #374151;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #0A2341;
    box-shadow: 0 0 0 3px rgba(10, 35, 65, 0.1);
    background: white;
}

.libro-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.libro-option {
    flex: 1;
    min-width: 200px;
}

.libro-option input[type="radio"] {
    display: none;
}

.libro-option label {
    display: block;
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.libro-option input[type="radio"]:checked + label {
    background: #0A2341;
    color: white;
    border-color: #0A2341;
}

.libro-option label:hover {
    border-color: #0A2341;
    background: #dce8f5;
}

.libro-option input[type="radio"]:checked + label:hover {
    background: #163357;
}

.search-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

body.page-busqueda .info-section {
    background: linear-gradient(135deg, #0A2341 0%, #163357 50%, #1e4a73 100%);
    color: white;
    padding: 2rem;
    border-radius: 12px;
    margin-top: 2rem;
}

body.page-busqueda .info-section h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

body.page-busqueda .info-section p {
    line-height: 1.6;
    opacity: 0.9;
}

/* ==============================================
   PAGE: RESULTADOS
   ============================================== */

.search-info {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(10, 35, 65, 0.1);
    border-left: 4px solid #0A2341;
}

.search-info h2 {
    margin-bottom: 1rem;
    color: #0A2341;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-criteria {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.criteria-item {
    background: rgba(10, 35, 65, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #0A2341;
    border: 1px solid rgba(10, 35, 65, 0.2);
}

.criteria-item strong {
    color: #0A2341;
}

.results-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.results-header {
    background: #0A2341;
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.results-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.table-container {
    overflow-x: auto;
}

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

.results-table th {
    background: #f8fafc;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.results-table td {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}

.results-table tr:hover {
    background: rgba(10, 35, 65, 0.05);
}

.action-btn {
    background: #0A2341;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.action-btn:hover {
    background: #163357;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(10, 35, 65, 0.3);
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: #6b7280;
}

.no-results-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.pagination {
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    border-top: 1px solid #e5e7eb;
}

.pagination a,
.pagination button {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: #374151;
}

.pagination a:hover:not(.disabled),
.pagination button:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #0A2341;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .active {
    background: #0A2341;
    color: white;
    border-color: #0A2341;
}

/* ==============================================
   PAGE: DETALLE
   ============================================== */

.breadcrumb {
    margin-bottom: 2rem;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.breadcrumb a {
    color: white;
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb a:hover {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: underline;
}

.detail-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.detail-header {
    background: #0A2341;
    color: white;
    padding: 2rem;
    text-align: center;
}

.detail-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.detail-subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
}

.detail-content {
    padding: 2rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

body.page-detalle .info-section {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1.5rem;
    border-left: 4px solid #0A2341;
    box-shadow: 0 2px 10px rgba(10, 35, 65, 0.1);
    color: #333;
}

body.page-detalle .info-section h3 {
    color: #0A2341;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-item {
    display: flex;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.info-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #374151;
    min-width: 140px;
    margin-right: 1rem;
}

.info-value {
    color: #6b7280;
    flex: 1;
    word-break: break-word;
}

.document-section {
    background: rgba(10, 35, 65, 0.05);
    border: 1px solid rgba(10, 35, 65, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.document-section h3 {
    color: #0A2341;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.document-content {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #374151;
    border: 1px solid rgba(10, 35, 65, 0.2);
    max-height: 300px;
    overflow-y: auto;
}

.actions-section {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-action {
    background: #0A2341;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(10, 35, 65, 0.2);
}

.btn-action:hover {
    background: #163357;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(10, 35, 65, 0.3);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
    color: white;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active {
    background: rgba(34, 197, 94, 0.1);
    color: #15803d;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-canceled {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ==============================================
   PDF VIEWER (Detalle)
   ============================================== */

.pdf-container {
    position: relative;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.pdf-header {
    background: #f8fafc;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pdf-controls {
    background: #0A2341;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.pdf-control-btn {
    background: #163357;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.pdf-control-btn:hover:not(:disabled) {
    background: #0d2845;
}

.pdf-control-btn:disabled {
    background: #64748b;
    cursor: not-allowed;
}

.pdf-page-info {
    font-weight: bold;
    margin: 0 10px;
    font-size: 0.9rem;
}

.pdf-viewer {
    position: relative;
    background: #f9fafb;
    min-height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    padding: 20px;
}

.pdf-canvas {
    max-width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    background: white;
}

.pdf-loading {
    text-align: center;
    color: #6b7280;
    font-size: 1.1rem;
    padding: 50px;
}

.pdf-error {
    text-align: center;
    color: #dc2626;
    font-size: 1.1rem;
    padding: 50px;
}

.pdf-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 6rem;
    font-weight: 900;
    color: rgba(220, 38, 38, 0.15);
    z-index: 1000;
    pointer-events: none;
    user-select: none;
    font-family: 'Arial Black', Arial, sans-serif;
    letter-spacing: 0.3em;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
    white-space: nowrap;
}

.pdf-watermark-multi {
    position: absolute;
    font-size: 3rem;
    font-weight: bold;
    color: rgba(220, 38, 38, 0.1);
    z-index: 999;
    pointer-events: none;
    user-select: none;
    font-family: 'Arial Black', Arial, sans-serif;
    transform: rotate(-45deg);
}

.pdf-watermark-1 { top: 20%; left: 20%; }
.pdf-watermark-2 { top: 20%; right: 20%; }
.pdf-watermark-3 { bottom: 20%; left: 20%; }
.pdf-watermark-4 { bottom: 20%; right: 20%; }

/* ==============================================
   MEDIA QUERIES
   ============================================== */

@media print {
    .pdf-container,
    .pdf-viewer {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    .main-title h1 {
        font-size: 2rem;
    }

    .services-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .search-form {
        padding: 1.5rem;
    }

    .libro-selector {
        flex-direction: column;
    }

    .libro-option {
        min-width: auto;
    }

    .search-buttons {
        flex-direction: column;
    }

    .search-criteria {
        justify-content: center;
    }

    .results-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .results-table {
        font-size: 0.9rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.5rem;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .info-item {
        flex-direction: column;
        gap: 0.25rem;
    }

    .info-label {
        min-width: auto;
        margin-right: 0;
    }

    .actions-section {
        flex-direction: column;
    }

    .pdf-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .pdf-controls {
        flex-direction: column;
        gap: 10px;
    }

    .pdf-watermark {
        font-size: 4rem;
    }
}

@media (max-width: 992px) and (min-width: 769px) {
    .services-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .service-card {
        padding: 1.5rem;
    }

    .service-card h3 {
        font-size: 1.3rem;
    }

    .service-card p {
        font-size: 0.9rem;
    }
}
