/* ============================================
   Twitter Photo Downloader
   Dark Mode Support with Light Mode Default
   Blue Theme for Social Media Tools
   ============================================ */

/* CSS Variables - Light Mode (Default) */
:root {
    --transition-speed: 0.25s;

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

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

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

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

    /* Border Colors */
    --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-full: 9999px;

    /* Input */
    --input-bg: #ffffff;
    --input-border: #bae6fd;
}

/* Dark Mode Colors */
[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;
}

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

/* Fix custom_styles.css clipping */
.tool-main {
    overflow: visible !important;
}

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

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

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

.tool-title i,
.tool-title svg {
    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;
}

/* Input Section */
.tpd-input-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

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

.tpd-input-header i,
.tpd-input-header svg {
    color: var(--primary);
}

.tpd-url-input-wrapper {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.tpd-url-input {
    flex: 1 1 0%;
    width: 0;
    min-width: 0;
    padding: 0.875rem 1rem;
    border: 2px solid var(--input-border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    background: var(--input-bg);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.tpd-url-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(51, 153, 204, 0.15);
}

.tpd-url-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.tpd-paste-btn {
    flex: 0 0 auto;
    width: 46px !important;
    height: auto !important;
    min-width: 46px;
    background: var(--bg-secondary) !important;
    border: 2px solid var(--border) !important;
    color: var(--text-muted) !important;
    cursor: pointer;
    padding: 0 !important;
    border-radius: var(--radius-md) !important;
    transition: color var(--transition-speed), background var(--transition-speed), border-color var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0 !important;
}

.tpd-paste-btn:hover {
    color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.tpd-paste-btn i,
.tpd-paste-btn svg {
    width: 20px;
    height: 20px;
}

.tpd-input-hints {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

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

.tpd-hint-item i,
.tpd-hint-item svg {
    color: var(--primary);
    flex-shrink: 0;
}

/* Buttons */
.tpd-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem !important;
    border-radius: var(--radius-md) !important;
    font-size: 0.95rem !important;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent !important;
    transition: all var(--transition-speed);
    text-decoration: none !important;
    line-height: 1.2;
    width: auto !important;
    height: auto !important;
}

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

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

.tpd-btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.tpd-btn-secondary {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border) !important;
}

.tpd-btn-secondary:hover {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}

.tpd-fetch-btn {
    width: 100% !important;
}

/* Supported Formats */
.tpd-supported-formats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
}

.tpd-formats-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.tpd-format-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
}

.tpd-format-tag i,
.tpd-format-tag svg {
    color: var(--primary);
}

/* Loading Section */
.tpd-loading-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    box-shadow: var(--shadow-md);
    text-align: center;
    margin-bottom: 1.5rem;
}

.tpd-loading-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--bg-secondary);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 1.25rem;
    animation: tpd-rotate 0.9s linear infinite;
}

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

.tpd-loading-text {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.tpd-loading-subtext {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-muted);
}

/* Results Section */
.tpd-results-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.tpd-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.tpd-results-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.25rem;
    color: var(--text);
}

.tpd-results-header h2 i,
.tpd-results-header h2 svg {
    color: var(--success);
}

.tpd-btn-new-url {
    display: inline-flex !important;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-full) !important;
    padding: 0.4rem 0.9rem !important;
    font-size: 0.82rem !important;
    font-weight: 600;
    cursor: pointer;
    width: auto !important;
    height: auto !important;
    transition: all var(--transition-speed);
}

.tpd-btn-new-url:hover {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}

.tpd-tweet-author {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.tpd-tweet-author i,
.tpd-tweet-author svg {
    color: var(--primary);
}

/* Quality Selector */
.tpd-quality-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
}

.tpd-quality-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.tpd-quality-label i,
.tpd-quality-label svg {
    color: var(--primary);
}

.tpd-quality-select {
    flex: 1 1 220px;
    min-width: 0;
    max-width: 320px;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.88rem;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-speed);
}

.tpd-quality-select:focus {
    border-color: var(--primary);
}

/* Single Result */
.tpd-single-result {
    text-align: center;
}

.tpd-single-preview {
    margin-bottom: 1rem;
}

.tpd-single-preview img {
    max-width: 100%;
    max-height: 480px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.tpd-single-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.tpd-meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-full);
}

.tpd-meta-badge i,
.tpd-meta-badge svg {
    color: var(--primary);
}

.tpd-single-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Gallery */
.tpd-gallery-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tpd-select-controls {
    display: flex;
    gap: 0.5rem;
}

.tpd-select-btn {
    background: transparent !important;
    border: 1px solid var(--border) !important;
    color: var(--text-secondary) !important;
    border-radius: var(--radius-full) !important;
    padding: 0.35rem 0.85rem !important;
    font-size: 0.8rem !important;
    font-weight: 600;
    cursor: pointer;
    width: auto !important;
    height: auto !important;
    transition: all var(--transition-speed);
}

.tpd-select-btn:hover {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}

.tpd-selected-count {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.tpd-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tpd-gallery-grid > * {
    min-width: 0;
}

.tpd-gallery-item {
    position: relative;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.tpd-gallery-item.selected {
    border-color: var(--primary);
    box-shadow: var(--shadow-primary);
}

.tpd-gallery-check {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 4px;
    display: flex;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

/* Checkbox overrides (custom_styles.css forces 20px blue checkboxes) */
.tpd-checkbox,
input[type="checkbox"].tpd-checkbox {
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    border: 1px solid var(--border) !important;
    background: var(--bg-elevated) !important;
    accent-color: var(--primary);
    cursor: pointer;
}

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

.tpd-gallery-thumb {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.tpd-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tpd-gallery-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.tpd-gallery-dl {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--primary) !important;
    cursor: pointer;
    padding: 0.3rem !important;
    width: auto !important;
    height: auto !important;
    font-size: 0 !important;
    transition: all var(--transition-speed);
}

.tpd-gallery-dl:hover {
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
}

.tpd-gallery-actions {
    text-align: center;
}

.tpd-zip-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.85rem 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.tpd-zip-hint i,
.tpd-zip-hint svg {
    color: var(--primary);
}

/* Error Display */
.tpd-error-message {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--danger-light);
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.tpd-error-message a {
    color: var(--danger);
    font-weight: 600;
    text-decoration: underline;
}

.tpd-error-message i,
.tpd-error-message svg {
    flex-shrink: 0;
}

.tpd-error-close {
    margin-left: auto;
    background: transparent !important;
    border: none !important;
    color: var(--danger) !important;
    cursor: pointer;
    padding: 0.25rem !important;
    display: inline-flex;
    width: auto !important;
    height: auto !important;
    font-size: 0 !important;
}

/* ============================================
   Below-tool Sections
   ============================================ */

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

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

.tpd-related-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
}

.tpd-related-label i,
.tpd-related-label svg {
    color: var(--primary);
}

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

.tpd-related-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-speed);
}

.tpd-related-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.tpd-related-link i,
.tpd-related-link svg {
    color: var(--primary);
}

/* Info Cards */
.tpd-info-sections {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tpd-info-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    box-shadow: var(--shadow-sm);
}

.tpd-info-card h2 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 1rem;
    font-size: 1.3rem;
    color: var(--primary);
}

.tpd-info-card h2 i,
.tpd-info-card h2 svg {
    color: var(--primary);
    flex-shrink: 0;
}

.tpd-info-card p {
    color: var(--text-secondary);
    font-size: 0.93rem;
    line-height: 1.7;
    margin: 0 0 0.85rem;
}

.tpd-info-card p:last-child {
    margin-bottom: 0;
}

.tpd-info-card a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

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

.tpd-steps-list {
    margin: 0 0 1rem;
    padding-left: 1.4rem;
    color: var(--text-secondary);
    font-size: 0.93rem;
    line-height: 1.7;
}

.tpd-steps-list li {
    margin-bottom: 0.65rem;
}

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

/* Quality / Format explanation grid */
.tpd-format-list,
.tpd-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.tpd-format-list > *,
.tpd-features-grid > * {
    min-width: 0;
}

.tpd-format-item,
.tpd-feature-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.2rem;
}

.tpd-format-item i,
.tpd-format-item svg,
.tpd-feature-item i,
.tpd-feature-item svg {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.tpd-format-item h4,
.tpd-feature-item h4 {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
    color: var(--text);
}

.tpd-format-item p,
.tpd-feature-item p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* FAQ */
.tpd-faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.tpd-faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-speed);
}

.tpd-faq-item.active {
    border-color: var(--primary);
}

.tpd-faq-question {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100% !important;
    height: auto !important;
    background: var(--bg-elevated) !important;
    border: none !important;
    color: var(--text) !important;
    font-size: 0.95rem !important;
    font-weight: 600;
    text-align: left;
    padding: 1rem 1.25rem !important;
    cursor: pointer;
    border-radius: 0 !important;
    transition: background var(--transition-speed);
}

.tpd-faq-question:hover {
    background: var(--bg-secondary) !important;
}

.tpd-faq-question i,
.tpd-faq-question svg {
    flex-shrink: 0;
    color: var(--primary);
    transition: transform var(--transition-speed);
}

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

.tpd-faq-answer {
    display: none;
    padding: 0 1.25rem 1.1rem;
    background: var(--bg-elevated);
}

.tpd-faq-item.active .tpd-faq-answer {
    display: block;
}

.tpd-faq-answer p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.tpd-faq-answer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

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

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

    .tpd-input-section,
    .tpd-results-section {
        padding: 1.25rem;
    }

    .tpd-related-tools,
    .tpd-info-sections {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

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

    .tpd-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .tpd-single-actions {
        flex-direction: column;
    }

    .tpd-single-actions .tpd-btn {
        width: 100% !important;
    }
}
