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

:root {
    /* Rust color palette */
    --rust-orange: #f74c00;
    --rust-orange-dark: #ce4300;
    --rust-orange-light: #ff6b1a;
    --rust-brown: #8b4513;
    --rust-copper: #b87333;
    --bg-dark: #1a1a1a;
    --bg-darker: #0f0f0f;
    --bg-card: #2a2a2a;
    --bg-card-hover: #333333;
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0a0;
    --text-muted: #707070;
    --border-color: #3a3a3a;
    --success: #22c55e;
    --error: #ef4444;
}

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

/* Navigation Bar */
.navbar {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--rust-orange);
    text-decoration: none;
    transition: opacity 0.3s;
}

.nav-brand:hover {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-links a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--rust-orange);
}

.user-info {
    color: var(--text-secondary);
    font-weight: 500;
}

.logout-btn {
    background: var(--error);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: #dc2626;
}

/* Container */
.container {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
}

.container.dashboard {
    max-width: 1200px;
}

/* Auth Card (Login/Signup) */
.auth-card {
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    padding: 40px;
    max-width: 500px;
    margin: 0 auto;
    border: 1px solid var(--border-color);
}

.auth-card h1 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 2em;
    text-align: center;
}

.subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.1em;
}

/* Form Styles */
.input-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="url"] {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
    background: var(--bg-dark);
    color: var(--text-primary);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="url"]:focus {
    outline: none;
    border-color: var(--rust-orange);
}

input[readonly] {
    background: var(--bg-darker);
}

.input-hint {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 0.9em;
}

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

button[type="submit"] {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--rust-orange) 0%, var(--rust-orange-dark) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(247, 76, 0, 0.4);
}

button[type="submit"]:active {
    transform: translateY(0);
}

button[type="submit"]:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* Error and Success Messages */
.error {
    color: var(--error);
    margin-top: 10px;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    display: none;
    border-left: 4px solid var(--error);
}

.error.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

.success {
    color: var(--success);
    margin-top: 20px;
    padding: 12px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 8px;
    display: none;
    border-left: 4px solid var(--success);
}

.success.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

.success a {
    color: var(--success);
    font-weight: 600;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Auth Switch Link */
.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--rust-orange);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Dashboard Styles */
.dashboard-header {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.dashboard-header h1 {
    color: var(--text-primary);
    font-size: 2.5em;
}

.create-section {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.create-section h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.urls-section {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    color: var(--text-primary);
    font-size: 1.5em;
}

.refresh-btn {
    background: var(--rust-orange);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.refresh-btn:hover {
    background: var(--rust-orange-dark);
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 1.1em;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-secondary);
}

/* URL Card */
.urls-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.url-card {
    background: var(--bg-dark);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
    border: 1px solid var(--border-color);
}

.url-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background: var(--bg-card-hover);
}

.url-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
    gap: 20px;
}

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

.url-name-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.url-name {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
}

.rename-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.rename-btn:hover {
    background: var(--bg-card-hover);
}

.rename-form {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.rename-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--rust-orange);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-darker);
    color: var(--text-primary);
}

.rename-input:focus {
    outline: none;
    border-color: var(--rust-orange-light);
}

.save-rename-btn,
.cancel-rename-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
}

.save-rename-btn {
    background: var(--success);
    color: white;
}

.save-rename-btn:hover {
    background: #16a34a;
}

.cancel-rename-btn {
    background: var(--border-color);
    color: var(--text-primary);
}

.cancel-rename-btn:hover {
    background: var(--text-muted);
}

.short-code {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--rust-orange);
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
}

.original-url {
    color: var(--text-secondary);
    font-size: 0.9em;
    word-break: break-all;
}

.url-stats {
    display: flex;
    gap: 20px;
}

.stat {
    text-align: center;
    background: var(--bg-card);
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.stat-value {
    display: block;
    font-size: 1.5em;
    font-weight: 700;
    color: var(--rust-orange);
}

.stat-label {
    display: block;
    font-size: 0.8em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.url-card-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.url-display {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-darker);
    color: var(--text-primary);
}

.copy-btn,
.visit-btn,
.qr-btn,
.delete-btn {
    padding: 10px 20px;
    background: var(--rust-orange);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.3s, opacity 0.3s;
    white-space: nowrap;
}

.copy-btn:hover,
.visit-btn:hover,
.qr-btn:hover,
.delete-btn:hover {
    background: var(--rust-orange-dark);
}

.copy-btn.copied {
    background: var(--success);
}

.visit-btn {
    background: var(--success);
}

.visit-btn:hover {
    background: #16a34a;
}

.qr-btn {
    background: #8b5cf6;
}

.qr-btn:hover {
    background: #7c3aed;
}

.delete-btn {
    background: var(--error);
}

.delete-btn:hover {
    background: #dc2626;
}

.delete-btn:disabled {
    background: #7f1d1d;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-content {
        flex-direction: column;
        gap: 15px;
    }

    .url-card-header {
        flex-direction: column;
        gap: 15px;
    }

    .url-card-actions {
        flex-direction: column;
    }

    .url-display {
        width: 100%;
    }

    .copy-btn,
    .visit-btn {
        width: 100%;
    }

    .auth-card {
        padding: 30px 20px;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-card);
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.3s, color 0.3s;
}

.modal-close:hover {
    background: var(--bg-darker);
    color: var(--text-primary);
}

.modal-body {
    padding: 30px;
    text-align: center;
}

.qr-image {
    max-width: 100%;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.qr-url {
    font-size: 0.9em;
    color: var(--text-muted);
    word-break: break-all;
    margin: 10px 0;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    justify-content: center;
}

.download-btn {
    padding: 12px 24px;
    background: var(--rust-orange);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.download-btn:hover {
    background: var(--rust-orange-dark);
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
    }

    .modal-footer {
        flex-direction: column;
    }

    .download-btn {
        width: 100%;
    }
}
