/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

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

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
main {
    flex: 1;
}

/* URL Input Section */
.url-input-section {
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    gap: 0.75rem;
    max-width: 100%;
}

#urlInput {
    flex: 1;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    transition: var(--transition);
    min-width: 0;
}

#urlInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

#urlInput::placeholder {
    color: var(--text-muted);
}

#checkBtn {
    padding: 1rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

#checkBtn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

#checkBtn:active {
    transform: translateY(0);
}

#checkBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.input-hint {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Error Section */
.error-section {
    margin-bottom: 2rem;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    border-radius: var(--radius);
    color: var(--error-color);
}

.error-icon {
    font-size: 1.25rem;
}

/* Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

#domainName {
    color: var(--primary-color);
}

/* Card Styles */
.preview-card,
.analysis-card,
.favicons-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.preview-card h3,
.analysis-card h3,
.favicons-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Browser Preview */
.browser-preview {
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.browser-tabs {
    display: flex;
    background: #1a1f2e;
    padding: 0.5rem 0.5rem 0;
}

.browser-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface-light);
    border-radius: 8px 8px 0 0;
    font-size: 0.875rem;
    max-width: 200px;
}

.browser-tab.active {
    background: var(--surface);
}

.browser-tab.inactive {
    background: transparent;
    color: var(--text-muted);
}

.tab-favicon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.browser-tab span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-close {
    margin-left: auto;
    color: var(--text-muted);
    cursor: pointer;
}

.tab-placeholder {
    padding: 0 0.5rem;
}

.browser-address-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
}

.address-icons {
    display: flex;
    gap: 0.75rem;
    color: var(--text-muted);
}

.address-input {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface-light);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.address-favicon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

/* Quality Analysis */
.quality-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.quality-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
}

.quality-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.quality-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.quality-value.good {
    color: var(--success-color);
}

.quality-value.warning {
    color: var(--warning-color);
}

.quality-value.bad {
    color: var(--error-color);
}

.quality-bar {
    height: 6px;
    background: var(--surface);
    border-radius: 3px;
    overflow: hidden;
}

.quality-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Favicon Grid */
.favicon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.favicon-item {
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.favicon-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.favicon-preview {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
}

.favicon-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

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

.favicon-size {
    font-weight: 600;
    color: var(--text-primary);
}

.favicon-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.favicon-source {
    font-size: 0.75rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.favicon-download {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.favicon-download:hover {
    background: var(--primary-hover);
}

/* Download All Section */
.download-section {
    text-align: center;
}

.download-all-btn {
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.download-all-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    filter: brightness(1.1);
}

.download-all-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Footer */
footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

footer a:hover {
    color: var(--primary-color);
}

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

    header h1 {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 1rem;
    }

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

    #checkBtn {
        width: 100%;
    }

    .browser-tab {
        max-width: 150px;
        padding: 0.5rem 0.75rem;
    }

    .quality-grid {
        grid-template-columns: 1fr;
    }

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

    .preview-card,
    .analysis-card,
    .favicons-card {
        padding: 1rem;
    }
}

/* Loading States */
.skeleton {
    background: linear-gradient(90deg, var(--surface-light) 25%, var(--surface) 50%, var(--surface-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Placeholder for missing favicons */
.favicon-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.5rem;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 1.5rem;
    background: var(--surface-light);
    color: var(--text-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

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

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}
