* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.form-container {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

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

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

.btn-secondary:hover {
    background-color: #475569;
}

.result-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: #f0fdf4;
    border: 2px solid var(--success-color);
    border-radius: 8px;
}

.success-message h2 {
    color: var(--success-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.short-url-display {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.short-url-display input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: white;
    font-family: monospace;
}

.info-text {
    color: var(--text-light);
    font-size: 0.9rem;
}

.error-container {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #fef2f2;
    border: 2px solid var(--error-color);
    border-radius: 8px;
}

.error-message {
    color: var(--error-color);
    margin: 0;
}

.links {
    text-align: center;
    margin-top: 2rem;
}

.link-btn {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.link-btn:hover {
    text-decoration: underline;
}

footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-light);
}

/* Redirect page styles */
.redirect-container {
    text-align: center;
    padding: 4rem 2rem;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Analytics dashboard styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.dashboard-section {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

.dashboard-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.url-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.url-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s;
}

.url-item:hover {
    box-shadow: var(--shadow);
}

.url-info {
    flex: 1;
    min-width: 0;
}

.url-short {
    font-family: monospace;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
    word-break: break-all;
}

.url-long {
    font-size: 0.9rem;
    color: var(--text-light);
    word-break: break-all;
    margin-bottom: 0.25rem;
}

.url-meta {
    font-size: 0.85rem;
    color: var(--text-light);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.url-stats {
    text-align: right;
}

.click-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.click-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

.last-updated {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

.loading {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
}

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

    header h1 {
        font-size: 2rem;
    }

    .form-container {
        padding: 1.5rem;
    }

    .short-url-display {
        flex-direction: column;
    }

    .url-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .url-stats {
        text-align: left;
        margin-top: 0.5rem;
    }

    .header-actions {
        flex-direction: column;
    }
}

/* Dark Mode Styles */
body.dark-mode,
[data-theme="dark"] body {
    background-color: #121212;
    color: #f9f9f9;
}

body.dark-mode,
[data-theme="dark"] {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #f9f9f9;
    --text-light: #a0a0a0;
    --border-color: #333;
}

body.dark-mode .form-container,
[data-theme="dark"] .form-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select,
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background-color: #1f1f1f;
    color: #f9f9f9;
    border-color: #555;
}

body.dark-mode .short-url-display input,
[data-theme="dark"] .short-url-display input {
    background-color: #1f1f1f;
    color: #f9f9f9;
    border-color: #555;
}

body.dark-mode .result-container,
[data-theme="dark"] .result-container {
    background-color: #1a3a1a;
    border-color: var(--success-color);
}

body.dark-mode .error-container,
[data-theme="dark"] .error-container {
    background-color: #3a1a1a;
    border-color: var(--error-color);
}

body.dark-mode .stat-card,
body.dark-mode .dashboard-section,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .dashboard-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

body.dark-mode .url-item,
[data-theme="dark"] .url-item {
    background: var(--card-bg);
    border-color: var(--border-color);
}

body.dark-mode .url-item:hover,
[data-theme="dark"] .url-item:hover {
    background: #2a2a2a;
}

body.dark-mode footer,
[data-theme="dark"] footer {
    border-top-color: var(--border-color);
}

/* Dark Mode Toggle - Floating Button with Popup */
.dark-mode-toggle-container {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 1000;
}

.dark-mode-toggle-button {
    width: 48px;
    height: 48px;
    background: rgba(243, 244, 246, 0.8);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    border: 1px solid rgba(209, 213, 219, 0.6);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.dark-mode-toggle-button:hover {
    background: rgba(229, 231, 235, 0.8);
    transform: scale(1.1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .dark-mode-toggle-button {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] .dark-mode-toggle-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.dark-mode-icon {
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

[data-theme="dark"] .dark-mode-icon {
    color: #ffffff;
}

.theme-icon-svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Popup Menu */
.dark-mode-popup {
    position: absolute;
    bottom: 56px;
    right: 0;
    width: 160px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(229, 231, 235, 0.6);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.2s ease;
    overflow: hidden;
}

.dark-mode-popup-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

[data-theme="dark"] .dark-mode-popup {
    background: rgba(31, 41, 55, 0.95);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Theme Options */
.theme-option {
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    font-size: 0.875rem;
    color: #374151;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

.theme-option:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.theme-option:last-child {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.theme-option:hover {
    background: rgba(243, 244, 246, 0.5);
}

[data-theme="dark"] .theme-option {
    color: #d1d5db;
}

[data-theme="dark"] .theme-option:hover {
    background: rgba(55, 65, 81, 0.5);
}

.theme-option-active {
    background: rgba(59, 130, 246, 0.1) !important;
    color: #2563eb !important;
}

[data-theme="dark"] .theme-option-active {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #93c5fd !important;
}

.theme-option-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-option-icon .theme-icon-svg {
    width: 16px;
    height: 16px;
}

.theme-option-label {
    font-weight: 500;
}

/* Responsive Dark Mode Toggle */
@media (max-width: 768px) {
    .dark-mode-toggle-container {
        bottom: 12px;
        right: 12px;
    }
    
    .dark-mode-toggle-button {
        width: 44px;
        height: 44px;
    }
    
    .theme-icon-svg {
        width: 18px;
        height: 18px;
    }
    
    .dark-mode-popup {
        bottom: 52px;
        width: 140px;
    }
}

