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

:root {
    --primary-color: #ff0000;
    --primary-dark: #cc0000;
    --success-color: #065fd4;
    --success-dark: #044ba0;
    --secondary-color: #606060;
    --background: #f9f9f9;
    --surface: #ffffff;
    --border: #e0e0e0;
    --text-primary: #0f0f0f;
    --text-secondary: #606060;
    --error: #cc0000;
    --warning: #f1c40f;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 40px 20px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

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

/* Main Sections */
main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

/* Form Styles */
.input-section {
    border-left: 4px solid var(--primary-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

input[type="url"],
input[type="text"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="url"]:focus,
input[type="text"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--success-color);
    box-shadow: 0 0 0 3px rgba(6, 95, 212, 0.1);
}

textarea {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    resize: vertical;
}

/* Cookies Section */
.cookies-section {
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}

.cookies-section summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--success-color);
    user-select: none;
}

.cookies-section summary:hover {
    color: var(--success-dark);
}

.cookies-section small {
    display: block;
    margin-top: 8px;
}

.cookies-section small a {
    color: var(--success-color);
    text-decoration: none;
}

.cookies-section small a:hover {
    text-decoration: underline;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #4a4a4a;
}

.btn-download {
    background: #27ae60;
    color: white;
}

.btn-download:hover {
    background: #229954;
}

/* Info Section */
.info-section {
    border-left: 4px solid var(--success-color);
}

#video-info {
    display: grid;
    gap: 12px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
    text-align: right;
}

/* Result Section */
.result-section {
    border-left: 4px solid #27ae60;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.result-header h2 {
    margin: 0;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.result-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--background);
    border-radius: var(--radius);
}

.meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: var(--surface);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.meta-tag.auto {
    background: #fff3cd;
    color: #856404;
}

.meta-tag.manual {
    background: #d4edda;
    color: #155724;
}

.meta-tag.warning {
    background: #f8d7da;
    color: #721c24;
}

#subtitles-content {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Loading Section */
.loading-section {
    text-align: center;
    padding: 40px;
}

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

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

#loading-message {
    color: var(--text-secondary);
}

/* Error Section */
.error-section {
    border-left: 4px solid var(--error);
    background: #fee;
}

.error-content {
    text-align: center;
}

.error-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 16px;
}

.error-content h3 {
    color: var(--error);
    margin-bottom: 8px;
}

.error-content p {
    color: var(--text-primary);
    line-height: 1.8;
}

/* Warning Section */
.warning-section {
    background: #fff3cd;
    border-left: 4px solid var(--warning);
}

.warning-section h3 {
    color: #856404;
    margin-bottom: 12px;
}

.warning-section p {
    margin-bottom: 12px;
}

.warning-section ul {
    margin-left: 24px;
    margin-bottom: 12px;
}

.warning-section li {
    margin-bottom: 8px;
}

.warning-section a {
    color: var(--success-color);
    text-decoration: none;
}

.warning-section a:hover {
    text-decoration: underline;
}

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

footer a {
    color: var(--success-color);
    text-decoration: none;
}

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

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    background: var(--text-primary);
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    z-index: 1000;
}

.toast.success {
    background: #27ae60;
}

.toast.error {
    background: var(--error);
}

@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    header h1 {
        font-size: 1.5rem;
    }

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

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-actions {
        width: 100%;
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }
}

/* Scrollbar Styling */
#subtitles-content::-webkit-scrollbar {
    width: 8px;
}

#subtitles-content::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: var(--radius);
}

#subtitles-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius);
}

#subtitles-content::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}
