/* RESET AND BASE STYLES */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: #f4f7f9;
    color: #333;
}

/* HEADER WITH DOCTOR INFO */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 10px 0;
    background: white;
    border-bottom: 2px solid #3498db;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.doctor-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.doctor-name {
    font-size: 20px;
    font-weight: bold;
    color: #2c3e50;
    line-height: 1.2;
    margin-bottom: 2px;
}

.doctor-title {
    font-size: 14px;
    color: #3498db;
    font-weight: 500;
    line-height: 1;
}

/* PATIENT INFO SECTION */
.patient-info {
    text-align: center;
    padding: 8px 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #17a2b8;
    margin-bottom: 10px;
    position: relative;
}

.patient-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.patient-label {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
}

.patient-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
    letter-spacing: 0.5px;
}

/* Make it stack on mobile */
@media (max-width: 768px) {
    .patient-header {
        flex-direction: column;
        gap: 2px;
    }

    .patient-info {
        padding: 6px 10px;
        margin-bottom: 8px;
    }

    .patient-label {
        font-size: 0.8rem;
    }

    .patient-name {
        font-size: 1rem;
    }
}

.patient-info.loaded {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 5-COLUMN LAYOUT - FULL VIEWPORT */
.main-container {
    display: grid;
    grid-template-columns: 20% 20% 20% 20% 20%;
    /* 5 equal columns */
    grid-template-rows: 1fr;
    height: calc(100vh - 60px);
    /* Account for fixed header */
    width: 100vw;
    gap: 0;
    margin: 0;
    padding: 0;
}

/* CONTROLS COLUMN (Column 1 - 20%) */
.controls-column {
    grid-column: 1;
    grid-row: 1;
    background: #f8f9fa;
    border-right: 2px solid #dee2e6;
    display: flex;
    flex-direction: column;
    padding: 5px;
    overflow-y: auto;
    box-sizing: border-box;
    max-height: calc(100vh - 60px);
}

/* MAIN CONTENT AREA (Columns 2-5 - 80%) */
.content-area {
    grid-column: 2 / 6;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
    box-sizing: border-box;
}

/* CONTROLS ROW ABOVE ODONTOGRAM */
.controls-row {
    flex-shrink: 0;
    display: flex;
    gap: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 10px;
    align-items: flex-start;
}

.dentition-selector,
.prestacion-selector {
    flex: 1;
}

.dentition-selector h3,
.prestacion-selector h3 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 12px;
    border-bottom: 1px solid #3498db;
    padding-bottom: 4px;
}

/* DENTITION SELECTOR RADIO BUTTONS */
.dentition-selector .radio-group input[type="radio"] {
    display: none;
}

.dentition-selector .layer-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    cursor: pointer;
    font-weight: 500;
    font-size: 12px;
    transition: all 0.2s ease;
    background: white;
}

.dentition-selector .layer-label:hover {
    border-color: #bbb;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dentition-selector .layer-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Active state for dentition selector */
.dentition-selector input[type="radio"]:checked+.layer-label {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
    font-weight: 600;
}

.dentition-selector input[type="radio"]:checked+.layer-label .layer-indicator {
    background: #3498db;
}

/* NOTES ROW BELOW ODONTOGRAM - SMALLER SIZE */
.notes-row {
    flex-shrink: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 10px;
    min-height: 120px;
    /* Much smaller */
    border: 2px solid #3498db;
}

.notes-section {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.notes-section h3 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 14px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 4px;
    flex-shrink: 0;
}

/* Textarea styling for notes - MUCH SMALLER */
.notes-section textarea {
    flex: 1;
    width: 100%;
    min-height: 80px;
    /* Much smaller */
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    resize: vertical;
    background: #fafafa;
    color: #333;
}

.notes-section textarea:focus {
    outline: none;
    border-color: #3498db;
    background: white;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.notes-section textarea::placeholder {
    color: #999;
    font-style: italic;
}

/* ODONTOGRAM ROW */
.odontogram-row {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 5px;
    height: 350px;
    overflow: hidden;
}



/* FLEXIBLE CONTENT SECTIONS */
.flexible-section {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    box-sizing: border-box;
}

.flexible-section h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 16px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

/* ODONTOGRAM SELECTOR - COMPACT FOR CONTROLS COLUMN */
.odontogram-selector {
    background-color: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.odontogram-selector label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

#odontogramType {
    padding: 4px 8px;
    border: 1px solid #3498db;
    border-radius: 4px;
    background: white;
    color: #2c3e50;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
}

.teeth-range {
    font-size: 12px;
    color: #7f8c8d;
    background: rgba(52, 152, 219, 0.1);
    padding: 4px 8px;
    border-radius: 12px;
}

/* LAYER TOGGLE PANEL - COMPACT FOR CONTROLS COLUMN */
.layer-toggle-panel {
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #e74c3c;
    margin-bottom: 10px;
}

.layer-toggle-panel h3 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 12px;
    border-bottom: 1px solid #e74c3c;
    padding-bottom: 4px;
}

.toggle-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
}

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

.layer-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    cursor: pointer;
    font-weight: 500;
    font-size: 12px;
    transition: all 0.2s ease;
    background: white;
}

.layer-label:hover {
    border-color: #bbb;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.layer-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layer-indicator.pre {
    color: #e74c3c;
    background: #e74c3c;
}

.layer-indicator.req {
    color: #3498db;
    background: #3498db;
}

/* Active state for layer labels */
input[type="radio"]:checked+.layer-label.pre-existing {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

input[type="radio"]:checked+.layer-label.required {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
}

.layer-description {
    background: rgba(52, 152, 219, 0.05);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid #3498db;
}

.layer-description p {
    margin: 0;
    font-size: 13px;
    color: #555;
}

/* CONTROLS PANEL - COMPACT BUTTONS */
.controls-panel {
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* BUTTON GRID - COMPACT SINGLE COLUMN FOR CONTROLS */
.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 2 columns of equal width */
    gap: 8px;
    /* Space between buttons */
    width: 100%;
    margin-bottom: 15px;
}

.button-grid button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    /* Reduced padding */
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #2d3748;
    color: white;
    font-size: 11px;
    /* Smaller font */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 60px;
    /* Fixed height for consistency */
    max-height: 60px;
    text-align: center;
}

/* Alternating colors for contrast */
.button-grid button:nth-child(even) {
    background: #718096;
    border-color: #4a5568;
}

.button-grid button .symbol {
    font-size: 14px;
    /* Smaller symbol */
    font-weight: bold;
    margin-bottom: 2px;
    line-height: 1;
    color: white;
}

.button-grid button .name {
    font-size: 9px;
    /* Very small text */
    font-weight: 500;
    line-height: 1.1;
    text-align: center;
    color: white;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* Limit to 2 lines */
    -webkit-box-orient: vertical;
}

/* Preserve important dental status colors */
#ODONTOGRAM_MODE_MIS .symbol {
    color: #e53e3e !important;
    /* Keep red X */
}

#ODONTOGRAM_MODE_UNE .symbol {
    color: #3182ce !important;
    /* Keep blue X */
}

/* Hover states */
.button-grid button:hover {
    background: #1a202c !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.button-grid button:nth-child(even):hover {
    background: #4a5568 !important;
}

/* Active/Selected state */
.button-grid button:active,
.button-grid button.active {
    background: #171923 !important;
    transform: translateY(0);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    border-color: #ffd700;
}

/* CONTROL BUTTONS - 2x2 GRID LAYOUT */
.control-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 2 columns */
    gap: 8px;
    margin-bottom: 15px;
    width: 100%;
}

.treatment-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 50px;
    text-align: center;
}

.treatment-btn .icon {
    font-size: 14px;
    margin-bottom: 2px;
}

.treatment-btn .name {
    font-size: 10px;
    font-weight: 600;
}

/* Control button colors */
.control-group .treatment-btn.delete-btn {
    background: #c53030 !important;
    color: white !important;
}

.control-group .treatment-btn.default-btn {
    background: #4a5568 !important;
    color: white !important;
}

.control-group .treatment-btn.download-btn {
    background: #38a169 !important;
    color: white !important;
}

.control-group .treatment-btn.export-btn {
    background: #805ad5 !important;
    color: white !important;
}

/* SPECIFIC BUTTON COLORS */
/* CARIES BUTTON - Blue color */
#ODONTOGRAM_MODE_CARIES {
    background: #6896ecff !important;
    color: white !important;
    border-color: #5a7fc7 !important;
}

/* RESTAURACION BUTTON - Red color */
#ODONTOGRAM_MODE_RES {
    background: #dc3545 !important;
    color: white !important;
    border-color: #c82333 !important;
}

/* Override alternating patterns for specific buttons */
#ODONTOGRAM_MODE_CARIES:nth-child(even) {
    background: #6896ecff !important;
    border-color: #5a7fc7 !important;
}

#ODONTOGRAM_MODE_RES:nth-child(even) {
    background: #dc3545 !important;
    border-color: #c82333 !important;
}

/* Hover states */
.control-group .treatment-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

#ODONTOGRAM_MODE_CARIES:hover {
    background: #5a7fc7 !important;
}

#ODONTOGRAM_MODE_RES:hover {
    background: #c82333 !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .patient-name {
        font-size: 1.2rem;
    }

    .patient-title {
        font-size: 0.8rem;
    }
}