/* ==========================================================================
   CSS Custom Variables & Baseline Resets
   ========================================================================== */
:root {
    --bg-main: #0b0f19;
    --bg-sidebar: #111827;
    --bg-card: rgba(30, 41, 59, 0.45);
    --bg-card-hover: rgba(30, 41, 59, 0.65);
    
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.25);
    --accent-active: #00d2ff;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-active: rgba(56, 189, 248, 0.5);
    
    --transition-speed: 0.25s;
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

h1, h2, h3, .brand-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ==========================================================================
   Layout Structures & Sidebar Responsive Components
   ========================================================================== */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* Off-canvas Overlay Backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 98;
}

/* Mobile Header View */
.mobile-header {
    display: none;
    height: 64px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Sidebar Styling */
.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 99;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 1.5rem;
    color: var(--accent);
    filter: drop-shadow(0 0 6px var(--accent-glow));
}

.brand-text {
    font-size: 1.35rem;
    font-weight: 700;
}

.accent-text {
    color: var(--accent);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 3rem;
    flex-grow: 1;
}

.nav-item {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.85rem 1.25rem;
    text-align: left;
    transition: all var(--transition-speed) ease;
}

.nav-item i {
    width: 20px;
    font-size: 1.1rem;
    text-align: center;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--border-active);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.1);
}

.sidebar-footer {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
    line-height: 1.4;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

/* Main Workspace Framework */
.workspace {
    padding: 3rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Animations & Tab Rendering */
.tab-content {
    display: none;
    animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Reusable UI/UX Elements (Glassmorphism, Components)
   ========================================================================== */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
}

.section-header {
    margin-bottom: 2.5rem;
}

.section-header h2 {
    font-size: 1.85rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Standardized Form Inputs */
input[type="text"], textarea {
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    padding: 0.85rem 1.25rem;
    width: 100%;
    transition: all var(--transition-speed) ease;
}

input[type="text"]:focus, textarea:focus {
    border-color: var(--accent-active);
    outline: none;
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.15);
}

/* Universal Button Implementations */
.btn {
    align-items: center;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.85rem 1.5rem;
    transition: all var(--transition-speed) ease;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--accent);
    color: #0b0f19;
}

.btn-primary:hover {
    background-color: var(--accent-active);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.35);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Functional Clipboard Buttons */
.copy-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
}

.copy-btn:hover {
    background: var(--accent-glow);
    border-color: var(--border-active);
    color: var(--accent);
}

/* Native CSS CSS Tooltips */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background-color: #0f172a;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
}

.tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* ==========================================================================
   Tool Section 1: Dashboard Panel
   ========================================================================== */
.hero-section {
    margin-bottom: 3.5rem;
}

.hero-section h1 {
    font-size: 2.75rem;
    margin-bottom: 0.75rem;
}

.font-glow {
    text-shadow: 0 0 15px var(--accent-glow);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.15rem;
    max-width: 750px;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.tool-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-speed) ease;
}

.tool-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-active);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-icon {
    font-size: 2rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
    display: inline-block;
}

.tool-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.tool-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.card-action {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: gap var(--transition-speed);
}

.tool-card:hover .card-action {
    gap: 0.75rem;
}

/* Dashboard Interactive Cards Accent Glows */
.card-glow {
    position: absolute;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    top: -60px;
    right: -60px;
    pointer-events: none;
    opacity: 0.5;
}

/* ==========================================================================
   Tool Section 2: Password Generator
   ========================================================================== */
.display-container {
    display: flex;
    gap: 0.75rem;
}

.display-container input {
    font-family: monospace;
    font-size: 1.15rem;
    letter-spacing: 0.05em;
    font-weight: 600;
    background: rgba(15, 23, 42, 0.7);
}

.strength-meter-wrapper {
    margin-top: 1.25rem;
}

.strength-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.strength-label span {
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 0.25rem;
}

.strength-bar-container {
    height: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

.strength-bar {
    height: 100%;
    width: 0%;
    transition: width var(--transition-speed) ease, background-color var(--transition-speed) ease;
}

/* Range Input Slider Components */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.slider-val {
    color: var(--accent);
    font-weight: 600;
    font-family: monospace;
    font-size: 1rem;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
    transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* Customized Grid Controls Checkboxes */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 32px;
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all var(--transition-speed) ease;
}

.checkbox-container:hover input ~ .checkmark {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--accent-glow);
    border-color: var(--accent);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid var(--accent);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ==========================================================================
   Tool Section 3: Text Utilities
   ========================================================================== */
.textarea-container {
    position: relative;
    width: 100%;
}

#textInput {
    height: 220px;
    resize: vertical;
    padding-right: 3.5rem;
    font-size: 0.95rem;
}

.absolute-copy {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.analytics-bar {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.metric-card {
    flex: 1;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.metric-val {
    font-weight: 600;
    font-family: monospace;
    font-size: 1.1rem;
}

.actions-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* ==========================================================================
   Tool Section 4: QR Code Generator
   ========================================================================== */
.two-col-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
}

.palette-input-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 1.1rem;
    justify-content: space-between;
}

.sub-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    background: none;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: 50%;
}

.qr-preview-box {
    width: 200px;
    height: 200px;
    background: #ffffff;
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#qrcode canvas, #qrcode img {
    max-width: 100%;
    max-height: 100%;
}

/* Display & Layout Alignment Utilities */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-column {
    flex-direction: column;
}

.gap-3 {
    gap: 1rem;
}

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }

/* ==========================================================================
   Tool Section 5: Color Palette & Swatches
   ========================================================================== */
.picker-container {
    position: relative;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    overflow: hidden; /* CRITICAL FIX: Blocks background color leaks outside circular wheel bounds */
    border: 5px solid var(--bg-card);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

.picker-container input[type="color"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0; /* Keeps color wheel visible behind standard input interaction */
    cursor: pointer;
    z-index: 2;
    border-radius: 50%;
}

.custom-color-trigger {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: transform var(--transition-speed) ease;
}

.custom-color-trigger i {
    font-size: 2rem;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.2);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.picker-container:hover .custom-color-trigger {
    transform: scale(1.04);
}

.picker-instruction {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.color-display-group {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1.25rem;
    border-radius: 8px;
}

.color-display-group .meta {
    display: flex;
    flex-direction: column;
}

.color-display-group .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.color-display-group .val {
    font-size: 1.05rem;
    font-weight: 600;
}

.font-mono {
    font-family: monospace;
}

/* ==========================================================================
   Responsive Adaptability (Media Queries)
   ========================================================================== */
@media (max-width: 1024px) {
    .two-col-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    /* Show Mobile Topbar Header */
    .mobile-header {
        display: flex;
    }

    /* Collapse Sidebar Off-Screen */
    .sidebar {
        position: fixed;
        left: -285px;
        top: 0;
        z-index: 99;
        width: 280px;
        transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.65);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Adapt Workspace Padding and Layout limits */
    .workspace {
        padding: 2rem 1.25rem;
        width: 100%;
    }

    .hero-section {
        margin-bottom: 2.5rem;
    }

    .hero-section h1 {
        font-size: 2.15rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    /* Redefine Text Actions stack for narrow Viewports */
    .actions-flex {
        flex-direction: column;
    }

    .actions-flex button {
        width: 100%;
        display: flex;
        justify-content: center;
        margin-left: 0 !important;
    }

    .analytics-bar {
        flex-direction: column;
        gap: 0.75rem;
    }

    .metric-card {
        padding: 0.85rem 1.25rem;
    }

    .options-grid {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }
    
    .display-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .display-container .copy-btn {
        width: 100%;
        height: 48px;
    }
}