/* CSS Design System for Glassmorphism & Premium Dark Theme */

:root {
    --bg-color: #0b0c10;
    --card-bg: rgba(22, 26, 37, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f5f6fa;
    --text-secondary: #a0aec0;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --hover-gradient: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    --input-bg: rgba(255, 255, 255, 0.06);
    --input-focus-border: rgba(59, 130, 246, 0.5);
    --danger-red: #ef4444;
}

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

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.5;
    padding: 2rem 0;
}

.container {
    width: 92%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* Header */
.hero-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo {
    display: inline-block;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.15em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.hero-header h1 {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 2.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

/* Tabs System */
.tabs-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0.4rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
    flex: 1;
    min-width: 120px;
    padding: 0.8rem 1rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--text-primary);
    background: var(--accent-gradient);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

/* Tab Content Visibility */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

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

/* Form Styles & Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

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

.form-group.full-width {
    grid-column: span 2;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.required {
    color: var(--danger-red);
    margin-left: 0.25rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.09);
    box-shadow: 0 0 0 3px var(--input-focus-border);
}

textarea {
    resize: vertical;
}

/* Cards layout inside tabs */
.card {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 1.8rem;
    margin-bottom: 1.5rem;
}

.card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #fff;
    border-left: 3px solid var(--accent-blue);
    padding-left: 0.75rem;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.mt-2 {
    margin-top: 1.5rem;
}

/* Radio robot-select-group */
.robot-select-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.robot-select-card {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.2rem 1.5rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.robot-select-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.robot-select-card input[type="radio"] {
    margin-right: 1.2rem;
    width: 20px;
    height: 20px;
    accent-color: var(--accent-blue);
}

.robot-card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.robot-badge {
    align-self: flex-start;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
    border-radius: 20px;
    margin-bottom: 0.3rem;
}

.robot-card-content strong {
    font-size: 1rem;
    color: #fff;
}

.robot-card-content span {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.robot-select-card:has(input[type="radio"]:checked) {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

/* Checkbox and switch utilities */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 400;
}

.checkbox-label input {
    margin-right: 0.6rem;
    accent-color: var(--accent-blue);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.3rem;
}

.radio-group label {
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.radio-group input {
    margin-right: 0.6rem;
    accent-color: var(--accent-blue);
}

/* Algorithm to inspection association list */
.algo-association-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.algo-assoc-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.2rem;
    transition: all 0.2s ease;
}

.algo-assoc-header {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
}

.algo-assoc-header input[type="checkbox"] {
    margin-top: 0.3rem;
    margin-right: 1rem;
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
}

.algo-assoc-title {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.algo-assoc-title strong {
    font-size: 0.95rem;
    color: #fff;
}

.algo-assoc-title span {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.algo-assoc-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Equipment Selection List Styling */
.equipment-selection-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.eq-selection-item {
    display: grid;
    grid-template-columns: 1.8fr 0.8fr 0.8fr 2fr;
    gap: 1rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.8rem 1.2rem;
    transition: background 0.2s;
}

.eq-selection-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.eq-item-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
}

.eq-item-checkbox input[type="checkbox"] {
    margin-right: 0.8rem;
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
}

.eq-selection-item input[type="number"],
.eq-selection-item input[type="text"] {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
}

.eq-selection-item.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Calculators section */
.calc-preview {
    margin-top: 1.5rem;
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    padding: 1.2rem;
}

.calc-preview h4 {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    color: #93c5fd;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.calc-item {
    background: rgba(0, 0, 0, 0.25);
    padding: 0.8rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.calc-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.calc-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    font-family: system-ui, -apple-system, sans-serif;
}

/* Dynamic Tables styling */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.btn-action {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #93c5fd;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-action:hover {
    background: rgba(59, 130, 246, 0.35);
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.data-table th, 
.data-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td input[type="text"],
.data-table td input[type="number"],
.data-table td select {
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.85rem;
}

.table-idx {
    text-align: center;
    background: transparent !important;
    border: none !important;
    color: var(--text-secondary);
}

.btn-delete {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Image upload styling */
.image-upload-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
}

.image-upload-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
}

.image-upload-card h4 {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.upload-dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    transition: all 0.2s ease;
}

.upload-dropzone:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.04);
}

.upload-icon {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.upload-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.img-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    display: none;
}

.upload-dropzone.has-image .img-preview {
    display: block;
}

.upload-dropzone.has-image .upload-icon,
.upload-dropzone.has-image .upload-text {
    display: none;
}

/* Form Actions */
.form-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

.btn-submit {
    background: var(--accent-gradient);
    color: #fff;
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 12px;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(139, 92, 246, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(139, 92, 246, 0.4);
    background: var(--hover-gradient);
}

/* Status Tracker Box */
.status-section {
    margin-top: 2.5rem;
}

.status-card {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 14px;
    padding: 1.8rem;
    text-align: center;
}

.status-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.spinner-container {
    margin: 1rem 0;
    display: flex;
    justify-content: center;
}

.loading-spinner {
    width: 35px;
    height: 35px;
    border: 3.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.status-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.progress-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    max-width: 400px;
    margin: 0 auto 1.5rem auto;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.btn-download {
    display: inline-block;
    background: var(--accent-gradient);
    color: #fff;
    padding: 0.8rem 1.8rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
    transition: all 0.2s;
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

/* History Dropdown styles */
.history-dropdown {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

.btn-history-dropdown {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-history-dropdown:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.history-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 460px;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(18, 18, 18, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(15px);
    padding: 10px;
}

.history-dropdown.active .history-dropdown-content {
    display: block;
}

#historyList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#historyList li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    gap: 10px;
}

#historyList li:last-child {
    border-bottom: none;
}

#historyList li span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 280px;
}

.history-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

#historyList li a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    font-size: 12px;
}

#historyList li a:hover {
    color: #60a5fa;
}

.btn-delete-history {
    background: none;
    border: none;
    color: #f87171;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    transition: color 0.2s;
}

.btn-delete-history:hover {
    color: #fca5a5;
}

.empty-history {
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    padding: 20px 0 !important;
    justify-content: center !important;
    border: none !important;
    background: transparent !important;
}

/* Adaptability / Responsiveness */
@media (max-width: 800px) {
    body {
        padding: 1rem 0;
    }
    .container {
        padding: 1.5rem;
    }
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .form-group.full-width {
        grid-column: span 1;
    }
    .checkbox-grid,
    .image-upload-grid {
        grid-template-columns: 1fr;
    }
    .tabs-nav {
        flex-direction: column;
    }
    .calc-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .eq-selection-item {
        grid-template-columns: 1.5fr 1fr;
        gap: 0.5rem;
    }
    .algo-assoc-details {
        grid-template-columns: 1fr;
    }
}
