/* ==================== */
/* Reset & Base Styles  */
/* ==================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

/* ==================== */
/* 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.7);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

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

.close-modal {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.3s;
}

.close-modal:hover {
    color: #333;
}

.modal-content h2 {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
    font-size: 1.8em;
}

.tutorial-step {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    align-items: flex-start;
}

.step-number {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2em;
    flex-shrink: 0;
}

.step-content h3 {
    color: #333;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.step-content p {
    color: #666;
    line-height: 1.6;
}

.tutorial-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #666;
    font-size: 0.9em;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* ==================== */
/* Container            */
/* ==================== */

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* ==================== */
/* Header               */
/* ==================== */

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

header h1 {
    font-size: 2.2em;
    margin-bottom: 5px;
    font-weight: 700;
}

.subtitle {
    font-size: 1em;
    opacity: 0.9;
}

.header-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.help-btn,
.doc-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.help-btn:hover,
.doc-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* ==================== */
/* Main Content         */
/* ==================== */

main {
    padding: 40px 30px;
}

section {
    animation: fadeIn 0.5s ease-in;
}

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

/* ==================== */
/* Upload Section       */
/* ==================== */

.upload-section {
    text-align: center;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 60px 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
    margin-top: 20px;
}

.upload-area:hover {
    border-color: #764ba2;
    background: #f0f2ff;
    transform: scale(1.02);
}

.upload-area.dragover {
    border-color: #764ba2;
    background: #e8ebff;
    transform: scale(1.05);
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.upload-area h2 {
    font-size: 1.5em;
    margin-bottom: 10px;
    color: #667eea;
}

.upload-area p {
    color: #666;
    margin-bottom: 5px;
}

.file-hint {
    font-size: 0.9em;
    color: #999;
    margin-top: 10px;
}

/* ==================== */
/* File Info            */
/* ==================== */

.file-info {
    margin: 30px 0;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.file-details {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
    border: 2px solid #667eea;
}

.file-icon {
    font-size: 2em;
}

.file-text {
    flex: 1;
    text-align: left;
}

.file-text strong {
    display: block;
    color: #333;
    margin-bottom: 5px;
}

.file-text span {
    color: #666;
    font-size: 0.9em;
}

.remove-btn {
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.remove-btn:hover {
    background: #ff3838;
    transform: scale(1.1);
}

/* ==================== */
/* Duration Control     */
/* ==================== */

.duration-control {
    margin: 30px 0;
    padding: 25px;
    background: #f8f9ff;
    border-radius: 10px;
}

.duration-control label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-weight: 600;
    color: #333;
}

.duration-value {
    color: #667eea;
    font-size: 1.2em;
    font-weight: 700;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    margin-bottom: 10px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #764ba2;
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.duration-hints {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: #999;
    margin-top: 5px;
}

/* ==================== */
/* Buttons              */
/* ==================== */

.split-btn,
.primary-btn,
.secondary-btn {
    padding: 15px 40px;
    font-size: 1.1em;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 20px auto;  /* Changed from "10px 5px" to center it */
    display: block;     /* Added to make margin: auto work */
    width: fit-content; /* Added to not stretch full width */
}

.split-btn,
.primary-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.split-btn:hover,
.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.split-btn:active,
.primary-btn:active {
    transform: translateY(0);
}

.split-btn:disabled,
.primary-btn:disabled,
.secondary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.secondary-btn {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.secondary-btn:hover {
    background: #f8f9ff;
    transform: translateY(-2px);
}

/* ==================== */
/* Processing Section   */
/* ==================== */

.processing-section {
    text-align: center;
    padding: 60px 30px;
}

.spinner-container {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 30px;
}

.spinner {
    width: 80px;
    height: 80px;
    border: 8px solid #f3f3f3;
    border-top: 8px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
    top: 0;
    left: 0;
}

.spinner-percentage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    z-index: 10;
}

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

/* Progress Bar Container */
.progress-bar-container {
    width: 100%;
    max-width: 400px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Progress Bar Background */
.progress-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Progress Bar Fill */
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: width 0.3s ease;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    position: relative;
}

.processing-section h3 {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 10px;
}

.processing-section p {
    color: #666;
    margin-top: 15px;
}

/* ==================== */
/* Results Section      */
/* ==================== */

.results-section {
    text-align: center;
}

.success-header {
    margin-bottom: 30px;
}

.success-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.success-header h2 {
    font-size: 2em;
    color: #333;
    margin-bottom: 10px;
}

.video-info {
    background: #f8f9ff;
    border-radius: 10px;
    padding: 25px;
    margin: 30px 0;
    text-align: left;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    color: #666;
    font-weight: 500;
}

.info-value {
    color: #333;
    font-weight: 600;
}

/* ==================== */
/* Segments             */
/* ==================== */

.segments-container {
    margin: 30px 0;
}

.segments-container h3 {
    text-align: left;
    margin-bottom: 20px;
    color: #333;
    font-size: 1.3em;
}

.segments-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.segment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
}

.segment-item:hover {
    border-color: #667eea;
    transform: translateX(5px);
}

.segment-info {
    flex: 1;
    text-align: left;
}

.segment-name {
    font-weight: 600;
    color: #333;
    display: block;
    margin-bottom: 5px;
}

.segment-details {
    font-size: 0.9em;
    color: #666;
}

.download-btn {
    padding: 10px 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.download-btn:hover {
    background: #764ba2;
    transform: scale(1.05);
}

.result-actions {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* ==================== */
/* Error Section        */
/* ==================== */

.error-section {
    text-align: center;
    padding: 60px 30px;
}

.error-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.error-section h2 {
    font-size: 1.8em;
    color: #ff4757;
    margin-bottom: 15px;
}

.error-message {
    color: #666;
    margin-bottom: 30px;
    padding: 20px;
    background: #fff5f5;
    border-radius: 10px;
    border-left: 4px solid #ff4757;
}

/* ==================== */
/* Footer               */
/* ==================== */

footer {
    background: #f8f9ff;
    padding: 30px;
    text-align: center;
    color: #666;
    border-top: 1px solid #e0e0e0;
}

footer p {
    margin: 5px 0;
}

footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    text-decoration: underline;
}

/* ==================== */
/* Responsive Design    */
/* ==================== */

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 10px;
    }

    header {
        padding: 20px;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    header h1 {
        font-size: 1.8em;
    }

    .header-buttons {
        width: 100%;
        justify-content: center;
    }

    main {
        padding: 30px 20px;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .result-actions {
        flex-direction: column;
    }

    .split-btn,
    .primary-btn,
    .secondary-btn {
        width: 100%;
    }

    .segment-item {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .segment-info {
        text-align: center;
    }

    .download-btn {
        width: 100%;
    }

    .modal-content {
        padding: 30px 20px;
        width: 95%;
    }

    .tutorial-footer {
        flex-direction: column;
        gap: 15px;
    }

    .tutorial-footer button {
        width: 100%;
    }
}

/* ==================== */
/* Animations           */
/* ==================== */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulsing {
    animation: pulse 2s ease-in-out infinite;
}

/* ==================== */
/* Auth Banner (index)  */
/* ==================== */

#authBanner a {
    color: #b45309;
    font-weight: 700;
    text-decoration: none;
}

#authBanner a:hover {
    text-decoration: underline;
}

/* ==================== */
/* Header auth buttons  */
/* ==================== */

.login-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.login-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* ==================== */
/* Shared Modal Overlay */
/* ==================== */

/* Ensure modals work on dashboard too */
.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* auth-btn class used in modal delete confirms */
.auth-btn {
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ==================== */
/* Crop Controls        */
/* ==================== */

.crop-options {
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    border: 1px solid #e5e7eb;
}

.crop-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.crop-field {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.crop-field label {
    font-size: .85em;
    font-weight: 600;
    color: #374151;
}

.crop-field select {
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: .9em;
    outline: none;
    background: #fff;
    cursor: pointer;
    transition: border-color .2s;
}

.crop-field select:focus { border-color: #667eea; }

.crop-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.crop-custom input {
    width: 120px;
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: .9em;
    outline: none;
    transition: border-color .2s;
}

.crop-custom input:focus { border-color: #667eea; }

/* ==================== */
/* Multi-file Queue     */
/* ==================== */

.file-queue-section {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: .9em;
    font-weight: 600;
    color: #374151;
}

.queue-clear-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: .85em;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s;
}

.queue-clear-btn:hover { background: #fef2f2; }

.file-queue {
    max-height: 240px;
    overflow-y: auto;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid #f3f4f6;
    font-size: .85em;
}

.queue-item:last-child { border-bottom: none; }

.queue-name {
    flex: 1;
    font-weight: 500;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-size { color: #9ca3af; white-space: nowrap; }

.queue-status { white-space: nowrap; font-weight: 600; }

.queue-remove-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1em;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all .15s;
    flex-shrink: 0;
}

.queue-remove-btn:hover { color: #ef4444; background: #fef2f2; }

/* ==================== */
/* Expiry notice        */
/* ==================== */

.expiry-notice {
    font-size: .85em;
    color: #92400e;
    background: #fef3c7;
    border-radius: 8px;
    padding: 6px 14px;
    display: inline-block;
    margin-top: 8px;
    font-weight: 600;
}