/* ============ XnTools Premium v3 - SaaS Dashboard ============ */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #161625;
    --bg-card: #1a1a2e;
    --bg-card-hover: #1e1e35;
    --bg-sidebar: #12121f;
    --bg-input: #1a1a2e;

    --accent-1: #6c5ce7;
    --accent-2: #a855f7;
    --accent-3: #ec4899;
    --accent-4: #3b82f6;
    --accent-5: #06b6d4;
    --accent-6: #10b981;
    --accent-7: #f59e0b;
    --accent-8: #ef4444;

    --text-primary: #e8e8f0;
    --text-secondary: #8888a8;
    --text-muted: #55556a;

    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    width: 100%; height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
    position: absolute; width: 100%; height: 100%;
    top: 0; left: 0;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.screen.active { opacity: 1; pointer-events: auto; z-index: 10; }

/* ============ LAYOUT ============ */
#homeScreen { display: flex; }

/* ============ SIDEBAR ============ */
.sidebar {
    width: 240px;
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 30;
    transition: var(--transition);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 18px;
    color: white;
}

.logo-text {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(108, 92, 231, 0.08);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-1);
}

.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; stroke: var(--accent-1); }

.nav-badge {
    margin-left: auto;
    background: var(--accent-1);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sidebar-badge {
    background: linear-gradient(135deg, var(--accent-7), var(--accent-8));
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 1px;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ============ TOPBAR ============ */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 15, 26, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    flex: 1;
    max-width: 400px;
    transition: var(--transition);
}

.topbar-search:focus-within {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.topbar-search svg { color: var(--text-muted); flex-shrink: 0; }

.topbar-search input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 100%;
    font-family: inherit;
}

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

.topbar-actions { margin-left: auto; }

.topbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--accent-6);
}

.status-dot {
    width: 8px; height: 8px;
    background: var(--accent-6);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============ HERO BANNER ============ */
.hero-banner {
    margin: 24px 28px 0;
    padding: 32px;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.15) 0%, rgba(168, 85, 247, 0.08) 50%, rgba(236, 72, 153, 0.08) 100%);
    border: 1px solid rgba(108, 92, 231, 0.2);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
}

.hero-banner::before {
    content: '';
    position: absolute;
    top: -50%; right: -20%;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(108, 92, 231, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.hero-banner::after {
    content: '';
    position: absolute;
    bottom: -30%; left: -10%;
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.hero-text h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-text p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.hero-stats {
    display: flex;
    gap: 16px;
}

.stat-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    text-align: center;
    min-width: 80px;
}

.stat-number {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--accent-1);
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ============ TOOLS SECTION ============ */
.tools-section {
    padding: 24px 28px;
    flex: 1;
}

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

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.tool-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* ============ TOOLS GRID ============ */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 14px;
}

/* ============ TOOL CARDS ============ */
.tool-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 14px 16px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--card-accent, var(--accent-1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tool-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px var(--border-hover);
}

.tool-card:hover::before { opacity: 1; }

.tool-card:active { transform: translateY(-2px); }

.tool-icon-wrapper {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: var(--icon-bg, rgba(108, 92, 231, 0.12));
    transition: var(--transition);
}

.tool-card:hover .tool-icon-wrapper {
    transform: scale(1.1);
}

.tool-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    letter-spacing: -0.1px;
}

.tool-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Card color variants */
.tool-card[data-color="purple"] { --card-accent: var(--accent-1); --icon-bg: rgba(108, 92, 231, 0.12); }
.tool-card[data-color="violet"] { --card-accent: var(--accent-2); --icon-bg: rgba(168, 85, 247, 0.12); }
.tool-card[data-color="pink"] { --card-accent: var(--accent-3); --icon-bg: rgba(236, 72, 153, 0.12); }
.tool-card[data-color="blue"] { --card-accent: var(--accent-4); --icon-bg: rgba(59, 130, 246, 0.12); }
.tool-card[data-color="cyan"] { --card-accent: var(--accent-5); --icon-bg: rgba(6, 182, 212, 0.12); }
.tool-card[data-color="green"] { --card-accent: var(--accent-6); --icon-bg: rgba(16, 185, 129, 0.12); }
.tool-card[data-color="amber"] { --card-accent: var(--accent-7); --icon-bg: rgba(245, 158, 11, 0.12); }
.tool-card[data-color="red"] { --card-accent: var(--accent-8); --icon-bg: rgba(239, 68, 68, 0.12); }

/* ============ TOOL VIEW ============ */
#toolView {
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

.tool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: rgba(15, 15, 26, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.back-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.back-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.tool-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    flex: 1;
}

.tool-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

/* ============ FORM STYLES ============ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ============ BUTTONS ============ */
.btn {
    padding: 11px 24px;
    background: var(--accent-1);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    background: #5a4bd6;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3);
}

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

.btn-full { width: 100%; }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    box-shadow: none;
}

.btn-group {
    display: flex;
    gap: 10px;
}

.btn-group .btn { flex: 1; }

/* ============ RESULT STYLES ============ */
.result-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 20px;
    word-break: break-all;
}

.result-box.success {
    border-left: 3px solid var(--accent-6);
}

.result-box.error {
    border-left: 3px solid var(--accent-8);
}

.result-box.warning {
    border-left: 3px solid var(--accent-7);
}

.result-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
}

.result-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.8;
}

.result-value code {
    background: rgba(108, 92, 231, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.82rem;
    color: var(--accent-2);
}

/* ============ COPY BUTTON ============ */
.copy-btn {
    background: var(--accent-1);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 14px;
    transition: var(--transition);
    font-family: inherit;
}

.copy-btn:hover {
    background: #5a4bd6;
    transform: translateY(-1px);
}

/* ============ SPINNER ============ */
.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent-1);
    border-radius: 50%;
    width: 32px; height: 32px;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

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

/* ============ TOAST ============ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    z-index: 1000;
    transition: var(--transition);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow);
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--accent-6); color: var(--accent-6); }
.toast.error { border-color: var(--accent-8); color: var(--accent-8); }

/* ============ INFO BOX ============ */
.info-box {
    background: rgba(108, 92, 231, 0.06);
    border: 1px solid rgba(108, 92, 231, 0.15);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.info-box strong { color: var(--accent-1); }

/* ============ TABLE ============ */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 14px;
}

table th {
    background: rgba(108, 92, 231, 0.08);
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--accent-1);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

table tr:hover { background: rgba(108, 92, 231, 0.04); }

/* ============ FOOTER ============ */
.footer {
    padding: 20px 28px;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* ============ SIDEBAR OVERLAY ============ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 25;
}

.sidebar-overlay.active { display: block; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(108, 92, 231, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(108, 92, 231, 0.4); }

/* ============ RESPONSIVE ============ */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar { display: none; }
    .sidebar.open {
        display: flex;
        position: fixed;
        top: 0; left: 0;
        height: 100%;
        z-index: 30;
    }
    .mobile-menu-btn { display: flex; }
    .hero-banner { margin: 16px 20px 0; padding: 24px; }
    .hero-content { flex-direction: column; text-align: center; }
    .hero-text h1 { font-size: 1.5rem; }
    .tools-section { padding: 20px; }
    .topbar { padding: 14px 20px; }
    .tools-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
}

/* Mobile */
@media (max-width: 640px) {
    .hero-banner { margin: 12px 14px 0; padding: 20px; }
    .hero-text h1 { font-size: 1.25rem; }
    .hero-text p { font-size: 0.8rem; }
    .hero-stats { gap: 10px; }
    .stat-card { padding: 10px 14px; min-width: 65px; }
    .stat-number { font-size: 1rem; }
    .stat-label { font-size: 0.6rem; }
    .tools-section { padding: 16px 14px; }
    .section-header { margin-bottom: 14px; }
    .section-header h2 { font-size: 1rem; }
    .tools-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    .tool-card { padding: 16px 10px 12px; gap: 8px; }
    .tool-icon-wrapper { width: 38px; height: 38px; font-size: 1.2rem; }
    .tool-name { font-size: 0.7rem; }
    .tool-desc { display: none; }
    .topbar { padding: 12px 14px; gap: 10px; }
    .topbar-search { padding: 7px 12px; }
    .topbar-status span:last-child { display: none; }
    .tool-content { padding: 20px 14px; }
    .tool-header { padding: 14px; }
    .tool-header h2 { font-size: 1rem; }
    .footer { padding: 16px 14px; }
    .form-group input,
    .form-group textarea,
    .form-group select { font-size: 16px; padding: 10px 12px; }
    .btn { padding: 10px 20px; font-size: 0.85rem; }
    .btn-group { flex-direction: column; }
}

/* Small mobile */
@media (max-width: 380px) {
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .tool-card { padding: 14px 8px 10px; }
    .tool-icon-wrapper { width: 34px; height: 34px; font-size: 1.1rem; }
    .tool-name { font-size: 0.68rem; }
}

/* Large desktop */
@media (min-width: 1400px) {
    .tools-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}
