/* ============================================
   Twitter GIF Maker
   Light Mode default, Dark Mode via [data-theme="dark"]
   Blue Theme (#3399cc) - paired with Twitter GIF Downloader
   Prefix: tgm-
   ============================================ */

:root {
    --transition-speed: 0.25s;

    /* Primary - Blue */
    --primary: #3399cc;
    --primary-light: #e0f2fe;
    --primary-dark: #2980b9;
    --accent: #60a5fa;

    /* Status */
    --success: #339966;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #e64e4e;
    --danger-light: #fee2e2;

    /* Backgrounds */
    --bg: #f0f9ff;
    --bg-elevated: #ffffff;
    --bg-secondary: #e0f2fe;
    --bg-tertiary: #bae6fd;

    /* Text */
    --text: #0c4a6e;
    --text-secondary: #075985;
    --text-muted: #6b7280;

    /* Borders */
    --border: #bae6fd;
    --border-light: #e0f2fe;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-primary: 0 4px 14px rgba(51, 153, 204, 0.25);
    --shadow-primary-hover: 0 6px 20px rgba(51, 153, 204, 0.35);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --input-bg: #ffffff;
    --input-border: #bae6fd;
}

[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-light: rgba(96, 165, 250, 0.15);
    --primary-dark: #3b82f6;
    --accent: #93c5fd;

    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);

    --bg: #0c1929;
    --bg-elevated: #152238;
    --bg-secondary: #1e3a5f;
    --bg-tertiary: #264a6e;

    --text: #e0f2fe;
    --text-secondary: #bae6fd;
    --text-muted: #a8a8b3;

    --border: #264a6e;
    --border-light: #1e3a5f;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
    --shadow-primary: 0 4px 14px rgba(96, 165, 250, 0.2);
    --shadow-primary-hover: 0 6px 20px rgba(96, 165, 250, 0.3);

    --input-bg: #1e3a5f;
    --input-border: #264a6e;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* Override custom_styles.css overflow:hidden which clips overlays */
.tool-main {
    overflow: visible !important;
}

.tool-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

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

.tgm-tool-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 0 0 0.75rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.tgm-tool-title i {
    color: var(--primary);
}

.tool-description {
    max-width: 800px;
    margin: 0 auto;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
}

.tool-description a {
    color: var(--primary);
    text-decoration: none;
}

.tool-description a:hover {
    text-decoration: underline;
}

/* Mode Tabs */
.tgm-mode-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--bg-elevated);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.tgm-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.tgm-tab:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.tgm-tab-active {
    background: var(--primary);
    color: #ffffff;
}

.tgm-tab-active:hover {
    background: var(--primary-dark);
    color: #ffffff;
}

/* Upload Section */
.tgm-upload-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.tgm-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed);
    background: var(--bg);
}

.tgm-dropzone:hover,
.tgm-dropzone.tgm-dropzone-drag {
    border-color: var(--primary);
    background: var(--primary-light);
}

.tgm-dropzone-icon {
    width: 56px;
    height: 56px;
    color: var(--primary);
    margin-bottom: 1rem;
}

.tgm-dropzone-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.tgm-dropzone-hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

/* File List */
.tgm-file-list {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tgm-file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.tgm-file-item i {
    color: var(--primary);
    flex-shrink: 0;
}

.tgm-file-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tgm-file-size {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tgm-file-remove {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: background var(--transition-speed);
}

.tgm-file-remove:hover {
    background: var(--danger-light);
}

/* Options Section */
.tgm-options-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.tgm-options-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--text);
    font-weight: 600;
    font-size: 1.1rem;
}

.tgm-options-header i {
    color: var(--primary);
}

.tgm-option-group {
    margin-bottom: 1.5rem;
}

.tgm-option-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.tgm-option-label i {
    color: var(--primary);
}

/* Preset Grid */
.tgm-preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.tgm-preset {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 0.5rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.tgm-preset:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.tgm-preset-active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.tgm-preset-shape {
    background: var(--primary);
    border-radius: 4px;
    opacity: 0.85;
}

.tgm-preset-active .tgm-preset-shape {
    opacity: 1;
}

.tgm-preset-square { width: 36px; height: 36px; }
.tgm-preset-landscape { width: 48px; height: 28px; }
.tgm-preset-portrait { width: 28px; height: 48px; }
.tgm-preset-original {
    width: 40px; height: 32px;
    background: transparent;
    border: 2px dashed var(--primary);
}

.tgm-preset-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.tgm-preset-dims {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Options Grid */
.tgm-options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.tgm-option label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.tgm-option label i { opacity: 0.7; }

.tgm-input,
.tgm-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition-speed);
}

.tgm-select { cursor: pointer; }

.tgm-input:focus,
.tgm-select:focus {
    border-color: var(--primary);
}

/* Checkboxes - scoped overrides to win cascade against custom_styles.css */
.tgm-checkbox-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.tgm-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
}

.tgm-checkbox-label input[type="checkbox"].tgm-checkbox {
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    border: 2px solid var(--border) !important;
    background: var(--bg-elevated) !important;
    accent-color: var(--primary) !important;
    cursor: pointer !important;
}

.tgm-checkbox-label input[type="checkbox"].tgm-checkbox:checked {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
}

/* Twitter Spec Note */
.tgm-twitter-spec {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: var(--primary-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

.tgm-twitter-spec i {
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

/* Buttons */
.tgm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
}

.tgm-btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-primary);
}

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

.tgm-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.tgm-btn-create {
    width: 100%;
}

.tgm-btn-secondary {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
}

.tgm-btn-secondary:hover {
    background: var(--bg-tertiary);
}

.tgm-btn-download {
    background: var(--success);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(51, 153, 102, 0.25);
}

.tgm-btn-download:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    color: #ffffff;
}

/* Processing Overlay - compress-gif spinner pattern */
.tgm-processing-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.tgm-processing-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    min-width: 340px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.tgm-stages {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 1.5rem;
}

.tgm-stage {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed);
}

.tgm-stage i {
    width: 20px;
    height: 20px;
}

.tgm-stage-active {
    background: var(--primary);
    color: #ffffff;
}

.tgm-stage-done {
    background: var(--success);
    color: #ffffff;
}

.tgm-stage-connector {
    width: 28px;
    height: 2px;
    background: var(--border);
    transition: background var(--transition-speed);
}

.tgm-stage-connector.tgm-stage-connector-done {
    background: var(--success);
}

.tgm-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.tgm-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.tgm-progress-pct {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.tgm-progress-status {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Result Section */
.tgm-result-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    text-align: center;
}

.tgm-result-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--success);
}

.tgm-result-header h2 {
    font-size: 1.35rem;
    margin: 0;
    color: var(--text);
}

.tgm-result-preview {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

.tgm-result-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.tgm-result-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.tgm-result-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.tgm-result-meta-item i {
    color: var(--primary);
}

.tgm-twitter-ready-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--success-light);
    color: var(--success);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.tgm-result-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

/* Error Toast */
.tgm-error-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9100;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
}

.tgm-error-toast i {
    color: var(--danger);
    flex-shrink: 0;
    margin-top: 2px;
}

.tgm-error-text {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.5;
}

.tgm-error-text a {
    color: var(--primary);
    text-decoration: none;
}

.tgm-error-text a:hover {
    text-decoration: underline;
}

.tgm-error-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
}

.tgm-error-close:hover {
    color: var(--text);
}

/* Related Tools */
.tgm-related-tools {
    max-width: 1000px;
    margin: 0 auto 2rem;
    padding: 0 2rem;
}

.tgm-related-tools-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.tgm-related-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.tgm-related-label i {
    color: var(--primary);
}

.tgm-related-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tgm-related-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all var(--transition-speed);
}

.tgm-related-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.tgm-related-link i {
    width: 16px;
    height: 16px;
}

/* Info Sections */
.tgm-info-sections {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem 2rem;
}

.tgm-info-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.tgm-info-card h2 {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 1.25rem;
}

.tgm-info-card h2 i {
    color: var(--primary);
}

.tgm-info-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 1.5rem 0 0.75rem;
}

.tgm-info-card p,
.tgm-info-card li {
    color: var(--text-muted);
    line-height: 1.7;
    margin: 0 0 0.75rem;
}

.tgm-info-card a {
    color: var(--primary);
    text-decoration: none;
}

.tgm-info-card a:hover {
    text-decoration: underline;
}

.tgm-info-card ul {
    padding-left: 1.5rem;
    margin: 0 0 1rem;
}

.tgm-info-card ul li strong {
    color: var(--text);
}

/* Steps List */
.tgm-steps-list {
    counter-reset: step;
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.tgm-steps-list li {
    position: relative;
    padding-left: 3rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.tgm-steps-list li::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.tgm-steps-list li strong {
    color: var(--text);
}

/* Features and Spec Grid */
.tgm-features-grid,
.tgm-spec-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.tgm-feature-item,
.tgm-spec-item {
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.tgm-feature-item i,
.tgm-spec-item i {
    color: var(--primary);
    margin-bottom: 0.75rem;
    display: block;
}

.tgm-feature-item h4,
.tgm-spec-item h4 {
    margin: 0 0 0.375rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.tgm-feature-item p,
.tgm-spec-item p {
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.5;
    color: var(--text-muted);
}

.tgm-spec-item a {
    color: var(--primary);
    text-decoration: none;
}

.tgm-spec-item a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .tool-container {
        padding: 1rem;
    }

    .tgm-tool-title {
        font-size: 1.35rem;
    }

    .tgm-upload-section,
    .tgm-options-section,
    .tgm-result-section {
        padding: 1.25rem;
    }

    .tgm-preset-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tgm-options-grid {
        grid-template-columns: 1fr;
    }

    .tgm-features-grid,
    .tgm-spec-list {
        grid-template-columns: 1fr;
    }

    .tgm-related-tools {
        padding: 0 1rem;
    }

    .tgm-info-sections {
        padding: 0 1rem 1rem;
    }

    .tgm-info-card {
        padding: 1.25rem;
    }

    .tgm-error-toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .tgm-dropzone {
        padding: 2rem 1rem;
    }

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