/* Professional Dashboard Style */
:root {
    --primary-color: #0066cc;
    --primary-hover: #0052a3;
    --success-color: #28a745;
    --success-light: #d4edda;
    --error-color: #dc3545;
    --error-light: #f8d7da;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

body {
    background-color: #f0f2f5;
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

/* Header */
.header {
    background-color: var(--bg-white);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Layout Wrapper */
.layout-wrapper {
    display: flex;
    min-height: auto;
    gap: 0;
    margin-bottom: 0;
}

/* Sidebar (Aside) */
.sidebar {
    width: 380px;
    background-color: var(--bg-light);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 96px);
    position: sticky;
    top: 96px;
}

/* Main Content (Body) */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background-color: #f0f2f5;
}

.header h1 {
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #0066cc 0%, #667eea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}


/* Card */
.card {
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-light);
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

/* Upload Form */
.upload-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

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

input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

.file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-light);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.file-label:hover {
    border-color: var(--primary-color);
    background-color: #e7f3ff;
    color: var(--primary-color);
}

.file-label span {
    font-weight: 500;
}

/* Buttons */
button[type="submit"] {
    background-color: var(--primary-color);
    color: white;
    padding: 0.625rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

button[type="submit"]:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

button[type="submit"]:active {
    transform: translateY(1px);
}

/* Messages */
.messages {
    margin-bottom: 1.5rem;
}

.message {
    padding: 0.875rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    font-size: 0.9375rem;
    border: 1px solid;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message.success {
    background-color: var(--success-light);
    color: #155724;
    border-color: #c3e6cb;
}

.message.error {
    background-color: var(--error-light);
    color: #721c24;
    border-color: #f5c6cb;
}

/* Results Section */
.results-card {
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-top: 1.5rem;
}

.results-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-light);
}

.results-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.results-header .file-name {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 0.5rem;
}

/* Download Button */
.json-download {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: #fafbfc;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--success-color);
    color: white;
    padding: 0.5rem 1.25rem;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.download-btn:hover {
    background-color: #218838;
    box-shadow: var(--shadow-md);
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.copy-btn:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--error-color);
    color: white;
    padding: 0.5rem 1.25rem;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.clear-btn:hover {
    background-color: #c82333;
    box-shadow: var(--shadow-md);
}

/* Results Content */
.results-content {
    padding: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
}

/* Calculation Results */
.calculation-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.calculation-card .results-header {
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.calculation-card .results-header h2 {
    color: white;
}

.calculation-card .results-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 0 0 8px 8px;
    max-height: none;
}

.calculation-result {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    gap: 0.5rem;
}

.result-label {
    font-size: 1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-value {
    font-size: 2.75rem;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.2;
}

.result-short {
    display: block;
    font-size: 1.125rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 0.75rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.3px;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

.calculation-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.detail-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.detail-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

.data-table tr {
    border-bottom: 1px solid var(--border-color);
}

.data-table tr:last-child {
    border-bottom: none;
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: left;
}

.data-table th {
    font-weight: 600;
    color: var(--text-primary);
    background-color: var(--bg-light);
    font-size: 0.875rem;
    width: 45%;
}

.data-table td {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.value-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.value-true {
    background-color: #d4edda;
    color: #155724;
}

.value-false {
    background-color: #f8d7da;
    color: #721c24;
}

.value-null {
    background-color: #fff3cd;
    color: #856404;
}

.value-number {
    background-color: #d1ecf1;
    color: #0c5460;
}

.results-content pre {
    background-color: #282c34;
    padding: 1.25rem;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    margin: 0;
}

.results-content code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.8;
    color: #abb2bf;
    display: block;
    white-space: pre;
}

/* JSON Syntax Highlighting */
.results-content pre code {
    color: #abb2bf;
}

/* Info text */
.info-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Results Grid - 2 ustun, 4 qator */
.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.grid-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.grid-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: #1a1f36;
    margin-bottom: 0.25rem;
}

/* Input with Icon - Yangi stil */
.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-light);
    border: 1.5px solid #e1e4e8;
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
    transition: all 0.2s ease;
}

.input-with-icon:hover {
    border-color: #c1c7cd;
    background: #fafbfc;
}

.input-with-icon:focus-within {
    border-color: var(--primary-color);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.08);
}

.edit-icon {
    color: #6c757d;
    flex-shrink: 0;
    margin-right: 0.5rem;
    transition: color 0.2s ease;
}

.input-with-icon:focus-within .edit-icon {
    color: var(--primary-color);
}

.styled-input,
.styled-select {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    padding: 0;
    outline: none;
    min-width: 0;
}

.styled-input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.styled-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5L6 8L9 5' stroke='%236c757d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.25rem center;
    padding-right: 1.5rem;
}

.input-unit {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

/* Recalculate Section */
.recalculate-section {
    display: flex;
    justify-content: center;
    padding-top: 1.25rem;
    margin-top: 1.25rem;
    border-top: 1px solid #e1e4e8;
}

.recalculate-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0052a3 100%);
    color: white;
    padding: 0.625rem 2rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.25);
    position: relative;
    overflow: hidden;
}

.recalculate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.recalculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 102, 204, 0.35);
}

.recalculate-btn:hover::before {
    left: 100%;
}

.recalculate-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
}

.recalculate-btn.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3) !important;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 160px);
    text-align: center;
    padding: 3rem 2rem;
    background: var(--bg-white);
    border-radius: 8px;
    border: 2px dashed var(--border-color);
}

.empty-state-icon {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.empty-state p {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 768px) {
    .layout-wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: none;
        position: relative;
        top: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
    }

    .main-content {
        padding: 1rem;
    }

    .header {
        padding: 1rem 1.25rem;
        position: relative;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .card-body {
        padding: 1rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    .data-table th {
        width: 40%;
    }

    .empty-state {
        min-height: 400px;
    }

    .result-value {
        font-size: 2rem;
    }

    .calculation-details {
        grid-template-columns: 1fr;
    }

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

    .grid-label {
        font-size: 0.75rem;
    }

    .input-with-icon {
        padding: 0.45rem 0.65rem;
        border-radius: 10px;
    }

    .styled-input,
    .styled-select {
        font-size: 0.8125rem;
    }

    .input-unit {
        font-size: 0.6875rem;
    }

    .edit-icon {
        width: 14px;
        height: 14px;
    }

    .recalculate-btn {
        padding: 0.5rem 1.5rem;
        font-size: 0.875rem;
        border-radius: 8px;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}

.loading-container {
    text-align: center;
    background-color: white;
    padding: 3rem 4rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.loading-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.loading-subtext {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

/* File History Card */
.history-card {
    margin-top: 1.5rem;
}

.history-card .results-header h2 {
    text-align: left;
    width: auto;
}

.history-table-wrapper {
    overflow-x: auto;
    padding: 0;
}

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

.history-table thead tr {
    background-color: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
}

.history-table th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-table th:nth-child(1) {
    width: 60px;
}

.history-table th:nth-child(2) {
    width: 32%;
}

.history-table th:nth-child(3) {
    width: 18%;
}

.history-table th:nth-child(4) {
    width: 28%;
}

.history-table th:nth-child(5) {
    width: 22%;
}

.history-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.history-table tbody tr:hover {
    background-color: #f8f9fa;
}

.history-table td {
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.file-name-cell {
    font-weight: 500;
    color: var(--primary-color);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.date-cell {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.sum-cell {
    font-weight: 600;
    color: var(--success-color);
}

.actions-cell {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: transparent;
}

.view-btn {
    color: var(--primary-color);
}

.view-btn:hover {
    background-color: rgba(0, 102, 204, 0.1);
    transform: scale(1.1);
}

.info-btn {
    color: #17a2b8;
}

.info-btn:hover {
    background-color: rgba(23, 162, 184, 0.1);
    transform: scale(1.1);
}

.delete-btn {
    color: var(--error-color);
}

.delete-btn:hover {
    background-color: rgba(220, 53, 69, 0.1);
    transform: scale(1.1);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--bg-white);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--primary-color) 0%, #0052a3 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.2s ease;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 2rem;
}

.modal-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: var(--bg-light);
    border-radius: 8px;
}

.info-row strong {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-row span {
    color: var(--text-primary);
    font-weight: 500;
}

.info-row.highlight {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.1) 0%, rgba(0, 82, 163, 0.1) 100%);
    border: 2px solid var(--primary-color);
    padding: 1rem 1.25rem;
}

.info-row.highlight strong {
    color: var(--primary-color);
    font-size: 1rem;
}

.sum-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success-color);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .history-table th,
    .history-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8125rem;
    }

    .file-name-cell {
        max-width: 120px;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-body {
        padding: 1.5rem;
    }

    .info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .actions-cell {
        gap: 0.25rem;
    }

    .action-btn {
        width: 32px;
        height: 32px;
    }
}