/* ===================== RESET & BASE ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
    --transition: .2s ease;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===================== HEADER ===================== */
.header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: #fff;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}
.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 60px;
}
.logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
}
.logo:hover { text-decoration: none; }
.logo-icon { font-size: 1.6rem; }

/* ===================== NAVIGATION ===================== */
.nav { display: flex; align-items: center; gap: 0; height: 100%; }
.nav-item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}
.nav-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.85);
    font-size: .875rem;
    padding: 0 .75rem;
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .3rem;
    transition: var(--transition);
    font-family: var(--font);
    white-space: nowrap;
}
.nav-btn:hover, .nav-item:hover .nav-btn { color: #fff; background: rgba(255,255,255,.1); }
.nav-btn .arrow { font-size: .6rem; transition: transform var(--transition); }
.nav-item:hover .arrow { transform: rotate(180deg); }

.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--transition);
    z-index: 100;
}
.nav-item:hover .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown a {
    display: block;
    padding: .6rem 1rem;
    color: var(--text);
    font-size: .875rem;
    transition: var(--transition);
}
.dropdown a:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }

/* ===================== SEARCH ===================== */
.search-box {
    position: relative;
    margin-left: 1rem;
}
.search-box input {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 20px;
    color: #fff;
    padding: .4rem 1rem .4rem 2.2rem;
    width: 200px;
    font-size: .85rem;
    outline: none;
    transition: var(--transition);
}
.search-box input::placeholder { color: rgba(255,255,255,.6); }
.search-box input:focus { background: rgba(255,255,255,.25); border-color: rgba(255,255,255,.5); width: 260px; }
.search-box .search-icon {
    position: absolute;
    left: .7rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: .85rem;
    opacity: .6;
}
.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 200;
    max-height: 300px;
    overflow-y: auto;
}
.search-results.active { display: block; }
.search-results a {
    display: block;
    padding: .5rem .8rem;
    color: var(--text);
    font-size: .85rem;
}
.search-results a:hover, .search-results a.highlighted { background: var(--primary-light); color: var(--primary); text-decoration: none; }

/* ===================== HAMBURGER ===================== */
.hamburger { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; padding: .5rem; }

/* ===================== MAIN CONTENT ===================== */
.main { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* Hero / Home */
.hero {
    text-align: center;
    padding: 3rem 1rem;
    background: linear-gradient(135deg, var(--primary-light) 0%, #ede9fe 100%);
    border-radius: var(--radius);
    margin-bottom: 2rem;
}
.hero h1 { font-size: 2rem; margin-bottom: .5rem; color: var(--primary-dark); }
.hero p { color: var(--text-light); max-width: 600px; margin: 0 auto 1.5rem; }

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}
.tool-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tool-card .icon { font-size: 2rem; margin-bottom: .5rem; }
.tool-card h3 { font-size: .95rem; margin-bottom: .25rem; }
.tool-card p { font-size: .8rem; color: var(--text-light); }

/* ===================== SECTIONS / PAGES ===================== */
.page { display: none; }
.page.active { display: block; }

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* Generator Card */
.gen-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}
.gen-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--primary-light);
}

/* ===================== FORMS ===================== */
.form-row {
    display: flex;
    gap: .75rem;
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.form-group label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .5px;
}
select, input[type="text"], input[type="number"], input[type="range"] {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem .75rem;
    font-size: .9rem;
    font-family: var(--font);
    outline: none;
    transition: var(--transition);
    background: #fff;
}
select:focus, input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ===================== RESULT DISPLAY ===================== */
.result-box {
    background: #f1f5f9;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 52px;
}
.result-value {
    font-family: var(--mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-dark);
    word-break: break-all;
    flex: 1;
    user-select: all;
}
.copy-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: .4rem .8rem;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
}
.copy-btn:hover { background: var(--primary-dark); }
.copy-btn.copied { background: var(--success); }

/* ===================== HISTORY ===================== */
.history-panel {
    margin-top: 1rem;
}
.history-toggle {
    background: none;
    border: none;
    color: var(--primary);
    font-size: .85rem;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem 0;
    font-family: var(--font);
}
.history-toggle:hover { text-decoration: underline; }
.history-list {
    display: none;
    margin-top: .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 250px;
    overflow-y: auto;
}
.history-list.open { display: block; }
.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .4rem .75rem;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: .85rem;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--primary-light); }
.history-actions {
    display: flex;
    gap: .5rem;
    margin-top: .5rem;
}

/* ===================== VALIDATOR ===================== */
.validator-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1rem 0;
}
.validator-result {
    margin-top: .5rem;
    padding: .5rem .75rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: .9rem;
}
.validator-result.valid { background: #dcfce7; color: #166534; }
.validator-result.invalid { background: #fee2e2; color: #991b1b; }

/* ===================== PROFILE TABLE ===================== */
.profiles-table-wrap {
    overflow-x: auto;
    margin: 1rem 0;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.profiles-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
    white-space: nowrap;
}
.profiles-table th {
    background: var(--primary);
    color: #fff;
    padding: .5rem .75rem;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
}
.profiles-table td {
    padding: .4rem .75rem;
    border-bottom: 1px solid var(--border);
}
.profiles-table tr:hover td { background: var(--primary-light); }

/* ===================== EXPORT MODAL ===================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 1rem; }
.modal .form-group { margin-bottom: .75rem; }
.modal .btn-group { margin-top: 1rem; justify-content: flex-end; }

/* ===================== PASSWORD STRENGTH ===================== */
.strength-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin: .5rem 0;
    overflow: hidden;
}
.strength-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .4s, background .4s;
    width: 0;
}
.strength-label { font-size: .85rem; font-weight: 600; }

/* ===================== TABS ===================== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1rem;
}
.tab-btn {
    background: none;
    border: none;
    padding: .6rem 1.2rem;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    font-family: var(--font);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===================== CHECKBOX / TOGGLE ===================== */
.toggle-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}
.toggle-label {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    cursor: pointer;
}
.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ===================== RANGE SLIDER ===================== */
.range-group {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.range-group input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
}
.range-value {
    font-family: var(--mono);
    font-weight: 700;
    min-width: 2rem;
    text-align: center;
}

/* ===================== TEXT AREA ===================== */
.text-result {
    width: 100%;
    min-height: 150px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    font-family: var(--font);
    font-size: .9rem;
    resize: vertical;
    background: #f8fafc;
    color: var(--text);
    line-height: 1.7;
}

/* ===================== FOOTER ===================== */
.footer {
    background: #1e293b;
    color: rgba(255,255,255,.7);
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 2rem;
}
.footer a { color: rgba(255,255,255,.9); }
.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: .75rem;
    flex-wrap: wrap;
    font-size: .85rem;
}

/* ===================== TOAST NOTIFICATION ===================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--success);
    color: #fff;
    padding: .75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all .3s;
    z-index: 9999;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
    .nav { display: none; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: #1e3a5f; padding: 1rem; gap: 0; height: auto; z-index: 999; }
    .nav.open { display: flex; }
    .nav-item { height: auto; flex-direction: column; }
    .nav-btn { padding: .6rem .75rem; justify-content: space-between; width: 100%; }
    .dropdown { position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none; background: rgba(255,255,255,.05); display: none; }
    .nav-item.open .dropdown { display: block; }
    .dropdown a { color: rgba(255,255,255,.8); }
    .dropdown a:hover { background: rgba(255,255,255,.1); color: #fff; }
    .hamburger { display: block; }
    .search-box { display: none; }
    .hero h1 { font-size: 1.5rem; }
    .tools-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .form-row { flex-direction: column; }
    .result-value { font-size: 1rem; }
    .header-inner { padding: 0 .75rem; }
}
