/**
 * GDPW Calculator Styles
 * Professional semiconductor wafer calculator interface
 */

/* Calculator Section */
.gdpw-calculator-section {
    padding: 80px 0;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    min-height: calc(100vh - 160px);
}

.calculator-header {
    text-align: center;
    margin-bottom: 60px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.calculator-title {
    font-size: clamp(2.5rem, 4vw, 3.5rem);
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.title-icon {
    font-size: 0.8em;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.1));
}

.calculator-subtitle {
    font-size: 1.125rem;
    color: #4a5568;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

/* Calculator Layout */
.calculator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 60px;
}

@media (max-width: 1024px) {
    .calculator-layout {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

/* Form Section */
.calculator-form-section {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.gdpw-form {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Form Sections */
.form-section {
    padding: 0;
}

.section-title {
    font-size: 1.375rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

/* Form Groups */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

.preset-group {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

/* Form Labels */
.form-label {
    font-weight: 500;
    color: #2d3748;
    font-size: 0.875rem;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-label::after {
    content: attr(data-unit);
    font-weight: 400;
    color: #718096;
    font-size: 0.75rem;
}

/* Form Controls */
.form-control {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
    font-family: 'Inter', sans-serif;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: #fefefe;
}

.form-control:invalid {
    border-color: #e53e3e;
}

.form-control:invalid:focus {
    border-color: #e53e3e;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.form-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

/* Hide default dropdown arrow in IE */
.form-select::-ms-expand {
    display: none;
}


/* Checkbox Styling */
.checkbox-group {
    padding: 16px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
    color: #2d3748;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
    background: white;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: #667eea;
    border-color: #667eea;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

@media (max-width: 640px) {
    .form-actions {
        flex-direction: column;
    }
}

.btn {
    padding: 14px 24px;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex: 1;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f7fafc;
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.btn-icon {
    font-size: 1.1em;
}

/* Form Errors */
.form-errors {
    background: #fed7d7;
    border: 1px solid #feb2b2;
    border-radius: 8px;
    padding: 16px;
}

.error-message {
    color: #c53030;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.error-message:last-child {
    margin-bottom: 0;
}

/* Results Section */
.calculator-results-section {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* Results Table */
.results-table-container {
    flex: 1;
}

.results-title {
    font-size: 1.375rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.results-title::before {
    content: '📊';
    font-size: 1.2em;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.results-table tr {
    border-bottom: 1px solid #e2e8f0;
}

.results-table tr:last-child {
    border-bottom: none;
}

.results-table td {
    padding: 16px 20px;
    vertical-align: middle;
}

.param-name {
    color: #4a5568;
    font-weight: 500;
    background: #f7fafc;
    font-size: 0.875rem;
    width: 60%;
}

.param-value {
    color: #2d3748;
    font-weight: 600;
    text-align: right;
    font-size: 1rem;
    font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;
}

.result-main {
    background: linear-gradient(135deg, #e6fffa 0%, #f0fff4 100%);
}

.result-main .param-name,
.result-main .param-value {
    color: #2d3748;
    font-size: 1.1rem;
}

.result-highlight {
    background: linear-gradient(135deg, #fef5e7 0%, #fff5f5 100%);
}

.result-highlight .param-name,
.result-highlight .param-value {
    color: #d69e2e;
    font-weight: 700;
}

/* Visualizations */
.visualizations-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    border-top: 1px solid #e2e8f0;
    padding-top: 40px;
}

.wafer-visualization,
.cell-visualization {
    background: #f7fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 20px;
}

.visualization-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 20px;
    text-align: center;
}

.visualization-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    padding: 20px;
    background: #f7fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

#wafer-canvas {
    width: 250px;
    height: 250px;
    border-radius: 50%;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    background: white;
}

.visualization-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: #4a5568;
    font-weight: 500;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #e2e8f0;
}

.wafer-color {
    background: #e2e8f0;
}

.useful-color {
    background: #c6f6d5;
}

/* Цвета для легенды ячейки - обновленная схема */
.cell-boundary-color {
    background: #2d3748;
}

.active-die-color {
    background: #48bb78; /* Зеленый для рабочих кристаллов */
}

.inactive-die-color {
    background: #e53e3e; /* Красный для заблокированных кристаллов */
}

.tm1-color {
    background: #3182ce; /* Синий для TM1 */
}

.tm2-color {
    background: #805ad5; /* Фиолетовый для TM2 */
}

.scribe-color {
    background: #a0aec0; /* Серый для scribe lines */
}

/* Устаревшие цвета - оставляем для совместимости */
.die-color {
    background: #48bb78; /* Теперь такой же как active-die-color */
}

.edge-color {
    background: #feb2b2;
}

.cell-color {
    background: #4299e1;
}

.edge-dies-color {
    background: #f6ad55;
}

.cell-bg-color {
    background: #e2e8f0;
}

.monitor-color {
    background: #3182ce; /* Теперь такой же как tm1-color */
}

.disabled-die-color {
    background: #e53e3e; /* Теперь такой же как inactive-die-color */
}

/* Calculator Info Section */
.calculator-info {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.calculator-info h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 30px;
    text-align: center;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.info-item {
    background: #f7fafc;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.info-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.info-item h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-item h4::before {
    content: '→';
    color: #667eea;
    font-weight: bold;
}

.info-item p {
    color: #4a5568;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Loading States */
.form-loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .gdpw-calculator-section {
        padding: 60px 0;
    }
    
    .visualizations-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .calculator-form-section,
    .calculator-results-section,
    .calculator-info {
        padding: 30px 20px;
    }
    
    .calculator-header {
        margin-bottom: 40px;
    }
    
    .calculator-title {
        font-size: 2rem;
        flex-direction: column;
        gap: 10px;
    }
    
    .visualization-container {
        padding: 15px;
    }
    
    #wafer-canvas {
        width: 200px;
        height: 200px;
        max-width: 100%;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .form-control {
        padding: 10px 14px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    
    .results-table td {
        padding: 12px 16px;
    }
    
    .param-name {
        font-size: 0.8rem;
    }
    
    .param-value {
        font-size: 0.9rem;
    }
}

/* Print Styles */
@media print {
    .gdpw-calculator-section {
        background: white;
        padding: 20px 0;
    }
    
    .calculator-form-section {
        display: none;
    }
    
    .calculator-layout {
        grid-template-columns: 1fr;
    }
    
    .calculator-results-section {
        box-shadow: none;
        border: 2px solid #e2e8f0;
        page-break-inside: avoid;
    }
    
    .wafer-visualization {
        page-break-inside: avoid;
    }
    
    .calculator-info {
        display: none;
    }
}

/* Animation Enhancements */
.form-group {
    animation: fadeInUp 0.6s ease-out;
}

.form-group:nth-child(1) { animation-delay: 0.1s; }
.form-group:nth-child(2) { animation-delay: 0.2s; }
.form-group:nth-child(3) { animation-delay: 0.3s; }
.form-group:nth-child(4) { animation-delay: 0.4s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus Management */
.form-control:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .form-control {
        border-width: 3px;
    }
    
    .btn-primary {
        background: #000;
        border: 2px solid #000;
    }
    
    .results-table {
        border: 2px solid #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .btn:hover {
        transform: none;
    }
    
    .info-item:hover {
        transform: none;
    }
}