/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Header wrapper */
.header-content-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-main {
    flex: 1;
}

/* Options Menu */
.options-menu {
    position: relative;
    margin-left: 20px;
}

.options-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: #6c757d;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.options-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #495057;
}

.options-panel {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    min-width: 220px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    margin-top: 5px;
    z-index: 9999;
}

.options-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.options-panel h4 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
}

.option-group {
    margin-bottom: 15px;
}

.option-group label {
    display: block;
    color: #495057;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}

.option-group select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.option-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

/* Custom checkbox styling */
.checkbox-label {
    display: flex !important;
    align-items: center;
    cursor: pointer;
    font-size: 14px !important;
    margin-bottom: 0 !important;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    margin-right: 10px;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background-color: #007bff;
    border-color: #007bff;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 12px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.checkbox-label:hover .checkmark {
    border-color: #007bff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    overflow-x: hidden;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: #6c757d;
}

/* Navigation */
.main-nav {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.search-section {
    margin-bottom: 25px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#searchInput {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    font-size: 16px;
}

#searchInput:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.25);
}

.search-section button {
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#searchBtn {
    background-color: #007bff;
    color: white;
}

#searchBtn:hover {
    background-color: #0056b3;
}

#clearBtn {
    background-color: #6c757d;
    color: white;
}

#clearBtn:hover {
    background-color: #545b62;
}

/* Alphabet navigation */
.alphabet-nav h3 {
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.1rem;
}

.alphabet-letters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.alphabet-letter {
    padding: 8px 12px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
}

.alphabet-letter:hover {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.alphabet-letter.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.alphabet-letter.no-medicines {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading indicator */
.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

/* Medicines list */
.medicines-list {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.medicine-item {
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background-color 0.2s;
}

.medicine-item:hover {
    background-color: #f8f9fa;
}

.medicine-item.selected {
    background-color: #e7f3ff;
    border-left: 4px solid #007bff;
    padding-left: 16px;
}

.medicine-item:last-child {
    border-bottom: none;
}

.medicine-name {
    font-size: 1.2rem;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0;
}

/* Medicine detail view */
.medicine-detail {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 30px;
    overflow-x: hidden;
    word-wrap: break-word;
}

.detail-header {
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.header-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

.detail-title {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 0;
}

.description-content {
    color: #495057;
    line-height: 1.6;
}

.description-content .detail-content {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

.detail-meta {
    color: #6c757d;
    font-size: 1rem;
}

.back-button {
    background-color: #6c757d;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 20px;
    font-size: 14px;
}

.back-button:hover {
    background-color: #545b62;
}

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

.detail-section h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.2rem;
    border-left: 4px solid #007bff;
    padding-left: 15px;
}

/* Primary section (Dosis y Pautas de Administración) */
.primary-section {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #dee2e6;
}

.primary-section h3 {
    color: #2c3e50;
    font-size: 1.3rem;
    margin-bottom: 15px;
    border-left: 4px solid #28a745;
}

/* Accordion styles */
.accordion-container {
    margin-bottom: 30px;
}

.accordion-section {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.accordion-header {
    width: 100%;
    background-color: #f8f9fa;
    border: none;
    padding: 15px 20px;
    text-align: left;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    color: #495057;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.accordion-header:hover {
    background-color: #e9ecef;
}

.accordion-header.open {
    background-color: #007bff;
    color: white;
}

.accordion-icon {
    font-size: 0.9rem;
    transition: transform 0.2s;
}

.accordion-content {
    background-color: white;
    overflow-x: hidden;
    word-wrap: break-word;
}

.accordion-content .detail-content {
    margin: 0;
    border-radius: 0;
}

/* Detail footer */
.detail-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
    color: #6c757d;
    font-size: 0.95rem;
}

.detail-footer p {
    margin-bottom: 8px;
}

.detail-footer a {
    color: #007bff;
    text-decoration: none;
    word-break: break-all;
}

.detail-footer a:hover {
    text-decoration: underline;
}

.detail-content {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 5px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

.detail-content strong {
    color: #2c3e50;
}

.detail-content p {
    margin-bottom: 15px;
}

.detail-content p:last-child {
    margin-bottom: 0;
}

.detail-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.detail-content li {
    margin-bottom: 5px;
    line-height: 1.6;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
    gap: 10px;
}

.pagination button {
    padding: 10px 15px;
    border: 1px solid #dee2e6;
    background-color: white;
    color: #495057;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

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

.pagination .page-info {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Footer */
.site-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    margin-top: 50px;
    padding: 30px 0;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    padding: 0 20px;
}

.footer-links {
    margin-bottom: 15px;
}

.footer-links a {
    color: #007bff;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.footer-links .separator {
    margin: 0 15px;
    color: #6c757d;
}

.footer-text {
    color: #6c757d;
    font-size: 0.9rem;
}

.footer-text p {
    margin: 0;
}

/* Legal pages styles */
.legal-content {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 30px;
    max-width: 800px;
    margin: 0 auto;
}

.back-link {
    margin-bottom: 20px;
}

.back-link a {
    color: #007bff;
    text-decoration: none;
    font-size: 0.95rem;
}

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

.legal-content h2 {
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.content-section {
    margin-bottom: 25px;
}

.content-section h3 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.content-section p {
    line-height: 1.7;
    color: #495057;
    margin-bottom: 15px;
}

.content-section a {
    color: #007bff;
    text-decoration: none;
}

.content-section a:hover {
    text-decoration: underline;
}

.warning-box {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-left: 4px solid #f39c12;
    border-radius: 5px;
    padding: 20px;
    margin: 15px 0;
}

.warning-box p {
    margin-bottom: 10px;
    color: #856404;
}

.warning-box p:last-child {
    margin-bottom: 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    /* Header responsive */
    .header-content-wrapper {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .header-main {
        margin-bottom: 15px;
    }
    
    /* Options menu responsive */
    .options-menu {
        margin-left: 0;
    }
    
    .options-toggle {
        font-size: 18px;
        padding: 6px;
    }
    
    .options-panel {
        min-width: 200px;
        padding: 12px;
        right: -50px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .main-nav {
        padding: 20px;
    }
    
    .search-section {
        flex-direction: column;
    }
    
    .search-section button {
        width: 100%;
    }
    
    .alphabet-letters {
        justify-content: center;
    }
    
    .medicine-detail {
        padding: 20px;
    }
    
    .detail-title {
        font-size: 1.5rem;
    }
    
    .header-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .primary-section {
        padding: 15px;
    }
    
    .accordion-header {
        padding: 12px 15px;
        font-size: 1rem;
    }
    
    .pagination {
        flex-wrap: wrap;
    }
    
    .legal-content {
        padding: 20px;
    }
    
    .legal-content h2 {
        font-size: 1.6rem;
    }
    
    .content-section h3 {
        font-size: 1.2rem;
    }
    
    .footer-links .separator {
        margin: 0 10px;
    }
}

@media (max-width: 480px) {
    /* Options menu mobile */
    .options-toggle {
        font-size: 16px;
        padding: 5px;
    }
    
    .options-panel {
        min-width: 180px;
        padding: 10px;
        right: -60px;
    }
    
    .alphabet-letters {
        gap: 5px;
    }
    
    .alphabet-letter {
        min-width: 35px;
        padding: 6px 8px;
        font-size: 14px;
    }
    
    .medicine-item {
        padding: 15px;
    }
    
    .medicine-name {
        font-size: 1.1rem;
    }
}