:root {
    --bg-main: #541A1A;
    --text-main: #F1E2D1;
    --text-muted: #DCC3AA;
    --primary: #810B38;
    --primary-hover: #F1E2D1;
    --accent-1: #DCC3AA;
    --accent-2: #810B38;
    --danger: #ef4444;
    --success: #10b981;
    --glass-bg: rgba(30, 0, 0, 0.6);
    --glass-border: rgba(241, 226, 209, 0.1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Dynamic Background Shapes */
.background-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite alternate ease-in-out;
}

.shape-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-1), transparent 70%);
    animation-delay: 0s;
}

.shape-2 {
    bottom: -20%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-2), transparent 70%);
    animation-delay: -5s;
}

.shape-3 {
    top: 40%;
    left: 60%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--primary), transparent 70%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.2); }
}

/* Glassmorphism Container */
.container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    z-index: 10;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-5px);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.6);
}

/* Typography */
header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.highlight {
    background: linear-gradient(135deg, #fcd34d, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 300;
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.input-row {
    display: flex;
    gap: 15px;
}

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    margin-left: 4px;
}

.optional {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 400;
}

input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
}

input::placeholder {
    color: rgba(220, 195, 170, 0.5);
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(129, 11, 56, 0.3);
    background: rgba(0, 0, 0, 0.6);
}

.alias-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.domain-prefix {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

#customAlias {
    padding-left: 28px;
}

/* Button */
button[type="submit"] {
    position: relative;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #3b1111;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

button[type="submit"]::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px #d97706;
}

button[type="submit"]:hover::before {
    left: 100%;
}

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

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* Loader */
.loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

.loading .btn-text { display: none; }
.loading .loader { display: block; }

/* Result Area */
.hidden {
    display: none !important;
}

.result-area {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid var(--glass-border);
    animation: slideUp 0.4s ease forwards;
}

.result-area h3 {
    font-size: 1.1rem;
    color: var(--success);
    margin-bottom: 12px;
    text-align: center;
}

.result-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 12px 16px;
    border-radius: 12px;
}

#shortLink {
    color: var(--text-main);
    font-weight: 600;
    text-decoration: none;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s;
}

#shortLink:hover {
    color: var(--success);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-main);
}

.stats-info {
    text-align: center;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.error-area {
    margin-top: 20px;
    padding: 15px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    color: #fca5a5;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideUp 0.3s ease forwards;
}

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

/* Responsive */
@media (max-width: 480px) {
    .input-row {
        flex-direction: column;
    }
    
    .glass-panel {
        padding: 30px 20px;
    }
    
    h1 {
        font-size: 2rem;
    }
}

/* ── Auth Tabs ─────────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: var(--glass-bg);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ── OTP Info ──────────────────────────────────────────────────────────────── */
.otp-info {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

.otp-info strong {
    color: var(--text-main);
}

/* ── API Key reveal ────────────────────────────────────────────────────────── */
.api-key-warn {
    color: #f59e0b;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 12px;
}

.result-area code {
    font-size: 0.8rem;
    word-break: break-all;
    color: var(--text-main);
}

/* ── Secondary Button ──────────────────────────────────────────────────────── */
.btn-secondary {
    width: 100%;
    margin-top: 14px;
    padding: 12px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
}

/* ── User Bar ──────────────────────────────────────────────────────────────── */
.user-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 6px;
    margin-bottom: 20px;
}

.user-email {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-logout {
    padding: 6px 14px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* ── Dashboard Layout & Panels ─────────────────────────────────────────────── */
.container.dashboard-active {
    max-width: 1200px;
    transition: max-width 0.4s ease;
}

.brand-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.brand-bar h1 {
    margin-bottom: 0;
}

.brand-bar .user-bar {
    margin: 0;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 30px;
    align-items: start;
    animation: fadeIn 0.4s ease;
}

@media (max-width: 992px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
}

.section-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
}

.section-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-main);
}

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

.section-header h3 {
    margin-bottom: 0;
}

/* ── Refresh button ── */
.btn-refresh {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-refresh:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

/* ── Shortened URLs List ── */
.urls-list-container {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.urls-list-container::-webkit-scrollbar {
    width: 6px;
}

.urls-list-container::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 3px;
}

.list-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.95rem;
}

.urls-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.url-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.url-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--primary);
    transform: translateX(4px);
}

.url-item.selected {
    background: rgba(129, 11, 56, 0.15);
    border-color: var(--primary);
}

.url-info-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.url-code {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-main);
}

.url-long {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.url-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.url-info-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.clicks-badge {
    background: var(--primary);
    color: var(--text-main);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ── Analytics Right Section ── */
.analytics-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    color: var(--text-muted);
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.8;
}

.analytics-content {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.active-link-info {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.active-link-info .title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.active-link-info h4 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-main);
}

.status-badge {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid var(--success);
    color: var(--success);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.truncated-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    word-break: break-all;
    margin-bottom: 10px;
}

.date-row {
    display: flex;
    gap: 15px;
}

.meta-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.stat-val {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

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

.chart-container {
    margin-bottom: 25px;
}

.chart-container h5 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.chart-wrapper {
    height: 200px;
    position: relative;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .breakdown-grid {
        grid-template-columns: 1fr;
    }
}

.breakdown-box h5 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.breakdown-item {
    position: relative;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    z-index: 1;
}

.breakdown-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(129, 11, 56, 0.15);
    z-index: -1;
    transition: width 0.6s ease;
}

.breakdown-name {
    font-weight: 600;
    color: var(--text-main);
}

.breakdown-count {
    color: var(--text-muted);
}

