/**
 * URL Shortener Premium Glassmorphic Stylesheet
 */

:root {
    /* Color Palette */
    --bg-primary: #0b0f19;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #141b2f;
    --bg-gradient-accent: #1e1b4b;
    
    --accent-cyan: #06b6d4;
    --accent-cyan-hover: #0891b2;
    --accent-indigo: #6366f1;
    --accent-indigo-hover: #4f46e5;
    --accent-purple: #a855f7;
    --accent-pink: #ec4899;
    
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;
    
    /* Text Colors */
    --text-main: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    /* Glassmorphism Tokens */
    --glass-bg: rgba(22, 30, 49, 0.45);
    --glass-bg-hover: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-focus: rgba(6, 182, 212, 0.4);
    --glass-shadow: rgba(0, 0, 0, 0.35);
    --glass-shadow-large: rgba(0, 0, 0, 0.55);
    
    /* Fonts */
    --font-family: 'Outfit', 'Sarabun', sans-serif;
    
    /* Transition */
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-spring: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

body {
    font-family: var(--font-family);
    background: radial-gradient(circle at 50% 100%, var(--bg-gradient-accent) 0%, var(--bg-gradient-end) 50%, var(--bg-primary) 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* Background Glowing Orbs */
.background-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.12;
    animation: orbPulse 8s ease-in-out infinite alternate;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--accent-cyan);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 600px;
    height: 600px;
    background: var(--accent-indigo);
    bottom: -150px;
    right: -100px;
    animation-delay: -3s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: var(--accent-purple);
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.06;
    animation-delay: -5s;
}

@keyframes orbPulse {
    0% {
        transform: scale(1) translate(0, 0);
        opacity: 0.08;
    }
    100% {
        transform: scale(1.15) translate(30px, 30px);
        opacity: 0.16;
    }
}

/* Glass Container Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--glass-shadow);
    transition: var(--transition-smooth);
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Inputs & Form Elements */
input[type="text"],
input[type="url"],
input[type="password"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(11, 15, 25, 0.55);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
    background: rgba(11, 15, 25, 0.75);
}

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

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: inline-block;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-spring);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(6, 182, 212, 0.4);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 24px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
}

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

.btn-icon.btn-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-danger);
    border-color: rgba(239, 68, 68, 0.3);
}

/* App Header & Wrapper */
.app-container {
    position: relative;
    z-index: 10;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 16px 80px 16px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--glass-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.brand h1 {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}

.user-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.user-info span {
    font-weight: 600;
    color: var(--text-main);
}

/* Dashboard KPI Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--accent-cyan);
}

.stat-card:nth-child(2) .stat-icon { color: var(--accent-indigo); }
.stat-card:nth-child(3) .stat-icon { color: var(--accent-purple); }
.stat-card:nth-child(4) .stat-icon { color: var(--accent-pink); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
}

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

/* Dashboard Main Layout */
.dashboard-main {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 24px;
    align-items: start;
}

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

/* URL Shortener Form Panel */
.shortener-panel {
    padding: 28px;
    position: sticky;
    top: 24px;
}

.shortener-panel h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group {
    margin-bottom: 18px;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-with-icon input {
    padding-left: 42px;
}

.prefix-input-group {
    display: flex;
    align-items: center;
    background: rgba(11, 15, 25, 0.55);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.prefix-input-group:focus-within {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
    background: rgba(11, 15, 25, 0.75);
}

.domain-prefix {
    padding: 0 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    border-right: 1px solid var(--glass-border);
    white-space: nowrap;
}

.prefix-input-group input {
    border: none;
    background: transparent;
    border-radius: 0;
}

.prefix-input-group input:focus {
    box-shadow: none;
    background: transparent;
}

/* Accordion Advanced Settings */
.advanced-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    color: var(--accent-cyan);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    margin-bottom: 16px;
    padding: 8px 0;
}

.advanced-trigger i {
    transition: var(--transition-smooth);
}

.advanced-trigger.active i {
    transform: rotate(180deg);
}

.advanced-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
}

.advanced-content.open {
    max-height: 400px; /* high enough limit */
    overflow-y: auto;
}

/* Links Management Table */
.manager-panel {
    padding: 28px;
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.manager-title {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    width: 280px;
}

@media (max-width: 640px) {
    .manager-header {
        flex-direction: column;
        align-items: stretch;
    }
    .search-box {
        width: 100%;
    }
}

.links-table-wrapper {
    overflow-x: auto;
    margin-top: 10px;
    flex-grow: 1;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 14px 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

.url-info-cell {
    max-width: 320px;
}

.url-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.short-link-anchor {
    color: var(--accent-cyan);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition-smooth);
}

.short-link-anchor:hover {
    color: var(--accent-indigo);
    text-decoration: underline;
}

.original-link-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin-top: 2px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-clicks {
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-lock {
    background: rgba(245, 158, 11, 0.12);
    color: var(--status-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-expiry {
    background: rgba(168, 85, 247, 0.12);
    color: var(--accent-purple);
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.badge-expired {
    background: rgba(239, 68, 68, 0.12);
    color: var(--status-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

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

.actions-cell {
    display: flex;
    gap: 6px;
}

/* Empty State */
.empty-state {
    padding: 64px 32px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    color: rgba(255, 255, 255, 0.05);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(15px);
    transition: var(--transition-spring);
}

.modal-overlay.active .modal-card {
    transform: scale(1) translateY(0);
}

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

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: var(--text-main);
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--glass-border);
    border-left: 4px solid var(--accent-cyan);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastIn {
    0% { transform: translateY(15px) scale(0.9); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.toast.toast-success { border-left-color: var(--status-success); }
.toast.toast-error { border-left-color: var(--status-danger); }
.toast.toast-warning { border-left-color: var(--status-warning); }

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

/* Analytics Layout inside Modal */
.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

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

.chart-wrapper {
    background: rgba(11, 15, 25, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 16px;
    min-height: 220px;
    display: flex;
    flex-direction: column;
}

.chart-wrapper-full {
    grid-column: 1 / -1;
    min-height: 280px;
}

.chart-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.analytics-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.analytics-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
}

.analytics-item-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.analytics-item-value {
    font-weight: 600;
    color: var(--accent-cyan);
}

/* Quick Shortener Result Display */
.shorten-result-card {
    background: rgba(6, 182, 212, 0.06);
    border: 1px dashed rgba(6, 182, 212, 0.3);
    border-radius: 14px;
    padding: 16px;
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: fadeIn 0.4s ease;
}

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

.result-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-cyan);
    text-transform: uppercase;
}

.result-row {
    display: flex;
    gap: 8px;
}

/* QR Code Modal Content */
.qr-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 20px;
    text-align: center;
}

.qr-code-wrapper {
    background: white;
    padding: 16px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.qr-download-btn {
    margin-top: 10px;
}

/* Custom Scrollbar for Glassmorphic styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}
