/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #7aa2ff;
    --primary-dark: #4f65ff;
    --secondary-color: #9f6bff;
    --accent-color: #5af1ff;
    --success-color: #3ad5ce;
    --danger-color: #ff6b81;
    --dark-bg: rgba(9, 4, 36, 0.85);
    --card-bg: rgba(14, 8, 46, 0.85);
    --text-primary: #f8f9ff;
    --text-secondary: #b5c0ff;
    --border-color: rgba(123, 128, 255, 0.24);
    --shadow: 0 28px 50px rgba(5, 2, 26, 0.55);
    --glow: 0 0 50px rgba(98, 140, 255, 0.45);
    --gradient: linear-gradient(135deg, #5c00d6 0%, #2533ff 45%, #00c6ff 100%);
    --gradient-soft: radial-gradient(circle at 12% 20%, rgba(92, 0, 214, 0.75) 0%, transparent 55%),
                     radial-gradient(circle at 88% 18%, rgba(0, 198, 255, 0.55) 0%, transparent 50%),
                     linear-gradient(125deg, rgba(9, 2, 34, 0.95) 0%, rgba(7, 0, 24, 0.9) 60%, rgba(16, 2, 48, 0.92) 100%);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #050117;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: -120px;
    background: var(--gradient-soft);
    filter: blur(80px);
    opacity: 1;
    z-index: -2;
}

.app-notice {
    max-width: 1400px;
    margin: 20px auto 0;
    padding: 14px 20px;
    border-radius: 16px;
    background: rgba(255, 215, 0, 0.12);
    border: 1px solid rgba(255, 220, 128, 0.4);
    color: #ffe9a0;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: 0 20px 30px rgba(9, 6, 27, 0.45);
    backdrop-filter: blur(18px);
}

.app-notice strong {
    color: #fff7c5;
    font-weight: 700;
    margin-right: 6px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* Header */
.header {
    text-align: center;
    padding: 58px 30px;
    background: rgba(10, 3, 40, 0.78);
    border-radius: 28px;
    margin-bottom: 56px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(96, 116, 255, 0.2);
    backdrop-filter: blur(24px);
    position: relative;
    overflow: hidden;
}

.header::after {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 24px;
    border: 1px solid rgba(118, 154, 255, 0.25);
    pointer-events: none;
}

.hero-media {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    z-index: 0;
}


.hero-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(1.15) brightness(0.6);
    transform: scale(1.08);
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(10, 2, 34, 0.65) 0%, rgba(7, 0, 24, 0.85) 65%, rgba(5, 0, 18, 0.92) 100%);
}

.brand-mark {
    position: absolute;
    top: 26px;
    left: 32px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(8, 2, 28, 0.7);
    border: 1px solid rgba(118, 154, 255, 0.35);
    box-shadow: 0 18px 40px rgba(6, 2, 32, 0.55);
    backdrop-filter: blur(14px);
    z-index: 2;
}

.brand-mark img {
    width: 46px;
    height: auto;
    filter: drop-shadow(0 10px 20px rgba(90, 190, 255, 0.35));
}

.brand-mark span {
    font-size: 0.95rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-primary);
    font-weight: 600;
}

.header-content {
    position: relative;
    z-index: 1;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo i {
    font-size: 3.6rem;
    color: var(--accent-color);
    text-shadow: 0 18px 38px rgba(90, 190, 255, 0.6);
}

.logo h1 {
    font-size: 3.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

.tagline {
    font-size: 1.05rem;
    color: rgba(181, 192, 255, 0.85);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.header-actions {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

/* Sections */
.section {
    background: rgba(12, 5, 40, 0.82);
    border-radius: 24px;
    padding: 36px;
    margin-bottom: 40px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(96, 116, 255, 0.2);
    backdrop-filter: blur(24px);
    position: relative;
}

.section h2 {
    font-size: 1.9rem;
    margin-bottom: 26px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section h2 i {
    color: var(--accent-color);
    text-shadow: 0 18px 34px rgba(90, 190, 255, 0.5);
}

/* Upload Area */

.upload-area {
    border: 2px dashed rgba(122, 146, 255, 0.45);
    border-radius: 22px;
    padding: 58px 50px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: rgba(20, 8, 58, 0.65);
    box-shadow: inset 0 0 0 1px rgba(96, 116, 255, 0.18);
}

.upload-area:hover {
    border-color: rgba(90, 161, 255, 0.9);
    background: linear-gradient(130deg, rgba(41, 28, 105, 0.92) 0%, rgba(18, 8, 58, 0.88) 50%, rgba(16, 27, 95, 0.9) 100%);
    transform: translateY(-6px);
    box-shadow: 0 32px 55px rgba(6, 2, 32, 0.7);
}

.upload-icon {
    font-size: 4.4rem;
    color: var(--accent-color);
    margin-bottom: 24px;
    display: block;
    text-shadow: 0 24px 44px rgba(90, 190, 255, 0.5);
}

.upload-area p {
    font-size: 1.05rem;
    color: rgba(181, 192, 255, 0.8);
    margin-bottom: 22px;
}

.upload-length-note {
    font-size: 0.92rem;
    color: rgba(255, 235, 179, 0.9);
    letter-spacing: 0.02em;
    margin-top: 6px;
}

/* Progress Bar */
.progress-container {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: rgba(34, 45, 120, 0.5);
    border-radius: 18px;
    overflow: hidden;
    margin-bottom: 12px;
    border: 1px solid rgba(96, 116, 255, 0.32);
}

.progress-fill {
    height: 100%;
    background: var(--gradient);
    width: 0%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

#progressText {
    text-align: center;
    color: var(--text-secondary);
}

/* Video Container */
.video-container {
    background: rgba(18, 8, 48, 0.9);
    border-radius: 22px;
    padding: 26px;
    margin-top: 26px;
    border: 1px solid rgba(96, 116, 255, 0.2);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}

#videoPreview {
    width: 100%;
    max-height: 500px;
    border-radius: 10px;
    background: #000;
}

.video-info {
    margin-top: 18px;
    padding: 20px 22px;
    background: rgba(26, 32, 90, 0.65);
    border-radius: 16px;
    border-left: 4px solid var(--accent-color);
    color: rgba(186, 197, 255, 0.88);
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.tool-card {
    background: rgba(12, 6, 42, 0.85);
    border-radius: 22px;
    padding: 30px;
    border: 1px solid rgba(100, 120, 255, 0.22);
    transition: all 0.35s ease;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(95, 120, 255, 0.18) 0%, rgba(89, 214, 255, 0.12) 45%, rgba(159, 107, 255, 0.14) 100%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 28px 55px rgba(6, 2, 32, 0.7);
    border-color: rgba(118, 154, 255, 0.6);
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.tool-header i {
    font-size: 1.6rem;
    color: var(--accent-color);
}

.tool-header h3 {
    font-size: 1.35rem;
    color: var(--text-primary);
}

.tool-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.structure-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    color: var(--text-primary);
}

.structure-table th,
.structure-table td {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    text-align: left;
    font-size: 0.98rem;
}

.structure-table th {
    font-size: 1rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(190, 198, 255, 0.85);
}

.structure-table tbody tr:hover {
    background: rgba(95, 120, 255, 0.08);
}

.sample-script p {
    color: rgba(190, 198, 255, 0.85);
}

.sample-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 6px;
}

.sample-list li {
    background: rgba(16, 12, 55, 0.65);
    border: 1px solid rgba(118, 154, 255, 0.22);
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 0.98rem;
    line-height: 1.5;
    box-shadow: inset 0 1px 0 rgba(95, 120, 255, 0.18);
}

.sample-list li strong {
    color: var(--accent-color);
    margin-right: 8px;
}

/* Input Groups */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.95rem;
    color: rgba(190, 198, 255, 0.85);
    font-weight: 600;
    letter-spacing: 0.03em;
}

.input-group input,
.input-group select,
.input-group textarea {
    padding: 14px 18px;
    border: 1px solid rgba(118, 154, 255, 0.35);
    border-radius: 16px;
    background: rgba(13, 22, 60, 0.75);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: inset 0 18px 40px rgba(5, 10, 35, 0.45);
}

.input-group textarea {
    min-height: 120px;
    resize: vertical;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: rgba(90, 161, 255, 0.85);
    box-shadow: 0 0 0 4px rgba(90, 161, 255, 0.25);
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Buttons */
.btn {
    padding: 13px 26px;
    border: none;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    text-decoration: none;
    background-size: 200% 200%;
    box-shadow: 0 22px 40px rgba(6, 2, 32, 0.6);
}

.btn:hover {
    transform: translateY(-6px);
    box-shadow: 0 32px 55px rgba(6, 2, 32, 0.75);
    background-position: 100% 0;
}

.btn:active {
    transform: translateY(-1px);
}

.btn-primary {
    background-image: var(--gradient);
    color: white;
}

.btn-secondary {
    background-image: linear-gradient(135deg, #9fa9ff 0%, #736dff 45%, #c47dff 100%);
    color: white;
}

.btn-success {
    background-image: linear-gradient(135deg, #1dd8c6 0%, #23b0ff 45%, #46f1ff 100%);
    color: white;
}

.btn-danger {
    background-image: linear-gradient(135deg, #ff4d8d 0%, #ff6e5b 45%, #ffb347 100%);
    color: white;
}

/* Status Section */
.status-card {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.status-card h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

#statusMessage {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Output Section */
.output-card {
    text-align: center;
    padding: 40px;
    background: rgba(12, 5, 42, 0.85);
    border-radius: 22px;
    border: 1px solid rgba(96, 116, 255, 0.2);
    box-shadow: var(--shadow);
}

.output-card p {
    font-size: 1.2rem;
    margin-bottom: 25px;
    color: rgba(179, 190, 255, 0.85);
}

.output-card .btn {
    margin: 0 10px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .logo h1 {
        font-size: 2rem;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

    .section {
        padding: 20px;
    }

    .output-card .btn {
        display: block;
        margin: 10px 0;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeIn 0.5s ease;
}

/* Frame Browser */
.frame-browser-button {
    text-align: center;
    padding: 20px;
    background: rgba(30, 24, 88, 0.6);
    border-radius: 18px;
    margin-bottom: 30px;
    border: 1px dashed rgba(118, 154, 255, 0.45);
}

.frame-controls {
    margin-bottom: 30px;
}

.frame-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 20px;
    padding: 20px;
    background: rgba(14, 24, 70, 0.65);
    border-radius: 16px;
    border: 1px solid rgba(96, 116, 255, 0.2);
}

.selected-count {
    margin-left: auto;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.1rem;
}

.frames-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.frame-item {
    position: relative;
    background: rgba(16, 8, 52, 0.85);
    border-radius: 18px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
}

.frame-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 18px 38px rgba(8, 2, 40, 0.65);
    border-color: rgba(122, 162, 255, 0.65);
}

.frame-item.selected {
    border-color: rgba(58, 213, 206, 0.8);
    box-shadow: 0 0 25px rgba(58, 213, 206, 0.45);
}

.frame-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.frame-info {
    padding: 12px;
    background: rgba(24, 36, 104, 0.6);
    color: rgba(179, 190, 255, 0.85);
}

.frame-timestamp {
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 5px;
}

.frame-index {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.frame-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    z-index: 10;
}

.frame-actions-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    z-index: 10;
}

.frame-actions-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(5, 1, 26, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: rgba(12, 6, 42, 0.92);
    padding: 32px;
    border-radius: 22px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid rgba(96, 116, 255, 0.22);
    backdrop-filter: blur(24px);
    box-shadow: var(--shadow);
}

.modal-large {
    max-width: 1000px;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--danger-color);
}

.modal-body {
    margin-top: 20px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: rgba(18, 10, 46, 0.6);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    padding: 20px 0;
}

.tab-content.active {
    display: block;
}

/* Frame Preview Container */
.frame-preview-container {
    position: relative;
    margin-bottom: 20px;
}

#frameCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Blemish UI */
.blemish-instructions {
    padding: 18px;
    background: rgba(28, 36, 112, 0.6);
    border-radius: 14px;
    margin-bottom: 20px;
    border-left: 4px solid var(--accent-color);
}

.blemish-instructions p {
    margin: 0;
    color: rgba(181, 192, 255, 0.82);
}

.blemish-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

#selectionInfo {
    font-weight: 600;
    padding: 10px;
    background: rgba(22, 34, 104, 0.7);
    border-radius: 10px;
    text-align: center;
    color: var(--text-primary);
}

/* Selection Rectangle on Canvas */
.selection-rect {
    stroke: var(--success-color);
    stroke-width: 2;
    fill: rgba(16, 185, 129, 0.2);
}
