/* ============================================
   Reddit GIF Downloader - reddit-gif-downloader.css
   Orange-Red Theme | Dark Mode Support | Light Default
   Prefix: rgd-
   ============================================ */

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

    --primary: #e64e4e;
    --primary-light: #fdeaea;
    --primary-dark: #c0392b;

    --success: #339966;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #e64e4e;
    --danger-light: #fdeaea;

    --bg: #fff8f7;
    --bg-elevated: #ffffff;
    --bg-secondary: #fdeaea;
    --bg-tertiary: #fbd5d5;

    --text: #3b0a0a;
    --text-secondary: #7b2020;
    --text-muted: #6b7280;

    --border: #fbd5d5;
    --border-light: #fdeaea;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.07);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.09);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.09);
    --shadow-primary: 0 4px 14px rgba(230, 78, 78, 0.22);
    --shadow-primary-hover: 0 6px 20px rgba(230, 78, 78, 0.32);

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

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

[data-theme="dark"] {
    --primary: #f87171;
    --primary-light: rgba(248, 113, 113, 0.15);
    --primary-dark: #ef4444;

    --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: #1a0a0a;
    --bg-elevated: #2b1010;
    --bg-secondary: #3a1515;
    --bg-tertiary: #4a1a1a;

    --text: #fee2e2;
    --text-secondary: #fca5a5;
    --text-muted: #a8a8b3;

    --border: #4a1a1a;
    --border-light: #3a1515;

    --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(248, 113, 113, 0.2);
    --shadow-primary-hover: 0 6px 20px rgba(248, 113, 113, 0.3);

    --input-bg: #3a1515;
    --input-border: #4a1a1a;
}

* { 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);
}

/* ---- Container ---- */
.rgd-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

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

.rgd-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);
}

.rgd-title svg { color: var(--primary); }

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

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

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

/* ---- Input Section ---- */
.rgd-input-section {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.rgd-input-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.rgd-url-wrapper {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.rgd-url-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.rgd-url-input::placeholder { color: var(--text-muted); }

.rgd-url-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.rgd-paste-btn {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-speed), transform 0.1s;
    flex-shrink: 0;
}

.rgd-paste-btn:hover { background: var(--primary-light); transform: scale(1.05); }

.rgd-hints {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.rgd-hint {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.rgd-hint svg { color: var(--primary); flex-shrink: 0; }

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

.rgd-btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
    box-shadow: var(--shadow-primary);
}

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

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

.rgd-btn-secondary {
    background: var(--bg-secondary);
    color: var(--primary);
    border: 1.5px solid var(--border);
}

.rgd-btn-secondary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.rgd-btn-success {
    background: var(--success);
    color: #fff;
}

.rgd-btn-success:hover { filter: brightness(0.9); }

.rgd-btn-sm {
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
}

/* ---- Supported formats ---- */
.rgd-formats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.rgd-format-tag {
    background: var(--bg-secondary);
    color: var(--primary);
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--border);
}

/* ---- Loading ---- */
.rgd-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 1.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    text-align: center;
}

.rgd-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: rgd-spin 0.8s linear infinite;
}

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

.rgd-loading-text {
    font-weight: 600;
    color: var(--text);
    font-size: 1rem;
}

.rgd-loading-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 300px;
}

/* ---- Progress Bar ---- */
.rgd-progress-wrap {
    width: 100%;
    max-width: 320px;
}

.rgd-progress-bar-bg {
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    height: 6px;
    overflow: hidden;
}

.rgd-progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    width: 0%;
}

/* ---- Error ---- */
.rgd-error {
    display: none;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--danger-light);
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--danger);
}

.rgd-error svg { flex-shrink: 0; margin-top: 2px; }

.rgd-error-body { flex: 1; font-size: 0.9rem; line-height: 1.5; }

.rgd-error-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--danger);
    padding: 0;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* ---- Results ---- */
.rgd-results {
    display: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.rgd-post-meta {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.rgd-post-meta svg { color: var(--primary); flex-shrink: 0; margin-top: 2px; }

.rgd-post-title {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.4;
}

.rgd-post-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.rgd-post-info span { margin-right: 0.75rem; }

/* ---- Media Grid ---- */
.rgd-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.rgd-media-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
    position: relative;
}

.rgd-media-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-primary);
    transform: translateY(-2px);
}

.rgd-media-card.selected {
    border-color: var(--primary);
    box-shadow: var(--shadow-primary);
}

.rgd-media-card.selected::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(230, 78, 78, 0.08);
    pointer-events: none;
}

.rgd-card-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    background: var(--bg-elevated);
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    z-index: 2;
}

.rgd-media-card.selected .rgd-card-check {
    background: var(--primary);
    border-color: var(--primary);
}

.rgd-card-check svg { display: none; color: #fff; }
.rgd-media-card.selected .rgd-card-check svg { display: block; }

.rgd-card-thumb-wrap {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.rgd-card-thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rgd-card-type-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.rgd-card-audio-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--success);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 3px;
}

.rgd-card-source-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.12rem 0.4rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rgd-card-info {
    padding: 0.6rem 0.75rem;
}

.rgd-card-dims {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.rgd-card-duration {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ---- Bulk Actions ---- */
.rgd-bulk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.rgd-select-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.rgd-select-info strong { color: var(--primary); }

.rgd-action-btns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---- Single Download Result ---- */
.rgd-download-result {
    display: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.rgd-result-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.rgd-result-header svg { color: var(--success); }

.rgd-result-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.rgd-result-body {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.rgd-result-preview {
    flex-shrink: 0;
    width: 160px;
}

.rgd-result-preview img,
.rgd-result-preview video {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.rgd-result-details { flex: 1; }

.rgd-result-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.rgd-stat-pill {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.rgd-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ---- GIF Convert Panel ---- */
.rgd-convert-panel {
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-top: 1rem;
}

.rgd-convert-title {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rgd-convert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.rgd-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.rgd-field select,
.rgd-field input[type="range"] {
    width: 100%;
}

.rgd-field select {
    padding: 0.45rem 0.75rem;
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
}

.rgd-field input[type="range"] {
    accent-color: var(--primary);
}

.rgd-range-val {
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 600;
}

/* ---- Warning Banner ---- */
.rgd-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: var(--warning-light);
    border: 1px solid var(--warning);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #92400e;
}

[data-theme="dark"] .rgd-warning { color: var(--warning); }

.rgd-warning svg { color: var(--warning); flex-shrink: 0; }

/* ---- Related Tools ---- */
.rgd-related-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.rgd-related-title {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rgd-related-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rgd-related-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-secondary);
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.rgd-related-pill:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* ---- Info Cards ---- */
.rgd-info-section {
    margin-bottom: 1.5rem;
}

.rgd-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.rgd-info-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.rgd-info-card-icon {
    color: var(--primary);
    margin-bottom: 0.6rem;
}

.rgd-info-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.4rem;
}

.rgd-info-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.55;
}

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

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

/* ---- FAQ ---- */
.rgd-faq-section {
    margin-bottom: 1.5rem;
}

.rgd-faq-section h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.rgd-faq-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.rgd-faq-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    text-align: left;
    gap: 0.75rem;
}

.rgd-faq-question svg {
    flex-shrink: 0;
    color: var(--primary);
    transition: transform 0.25s;
}

.rgd-faq-item.active .rgd-faq-question svg { transform: rotate(180deg); }

.rgd-faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.2s;
    padding: 0 1.25rem;
}

.rgd-faq-item.active .rgd-faq-answer {
    max-height: 300px;
    padding: 0 1.25rem 1rem;
}

.rgd-faq-answer p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
}

.rgd-faq-answer a {
    color: var(--primary);
    text-decoration: none;
}

.rgd-faq-answer a:hover { text-decoration: underline; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .rgd-container { padding: 1rem; }
    .rgd-title { font-size: 1.35rem; }
    .rgd-media-grid { grid-template-columns: repeat(2, 1fr); }
    .rgd-result-body { flex-direction: column; }
    .rgd-result-preview { width: 100%; }
    .rgd-convert-grid { grid-template-columns: 1fr 1fr; }
}
