:root {
    --font: 'Poppins', sans-serif;
}

/* ================= TEMA OSCURO ================= */
body.dark-mode {
    --bg-main: #0F111A;
    --bg-gradient: radial-gradient(circle at 0% 0%, rgba(92, 124, 231, 0.2), transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(0, 210, 211, 0.15), transparent 50%),
        linear-gradient(135deg, #0F111A 0%, #1A1C2E 100%);
    --glass-bg-base: rgba(25, 28, 45, 0.6);
    --card-bg-base: rgba(25, 28, 45, 0.3);
    --glass-border: rgba(255, 255, 255, 0.12);
    --internal-glow-1: radial-gradient(circle at 20% 20%, rgba(92, 117, 231, 0.25) 0%, transparent 60%);
    --internal-glow-2: radial-gradient(circle at 80% 80%, rgba(0, 210, 211, 0.15) 0%, transparent 60%);
    --primary: #5ca8e7;
    --primary-glow-box: 0 0 25px rgba(92, 175, 231, 0.5);
    --accent: #00D2D3;
    --shadow-glass: 0 15px 35px -10px rgba(0, 0, 0, 0.6), inset 0 1px 0 0 rgba(255, 255, 255, 0.2);
    --text-main: #FFFFFF;
    --text-muted: #A0A0B8;
    --input-bg: rgba(15, 17, 26, 0.7);
    --input-border: rgba(255, 255, 255, 0.08);
    --dropdown-bg: #1A1C2E;
}

/* ================= TEMA CLARO ================= */
body.light-mode {
    --bg-main: #F0F2F5;
    --bg-gradient: radial-gradient(circle at 100% 0%, rgba(9, 132, 227, 0.15), transparent 40%),
        linear-gradient(135deg, #E8ECF2 0%, #FFFFFF 100%);
    --glass-bg-base: rgba(255, 255, 255, 0.65);
    --card-bg-base: rgba(255, 255, 255, 0.3);
    --glass-border: rgba(255, 255, 255, 0.8);
    --internal-glow-1: radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.95) 0%, transparent 55%);
    --internal-glow-2: radial-gradient(circle at 90% 90%, rgba(9, 132, 227, 0.1) 0%, transparent 60%);
    --primary: #0984E3;
    --primary-glow-box: 0 5px 20px rgba(9, 132, 227, 0.25);
    --accent: #00CEC9;
    --shadow-glass: 0 10px 30px -10px rgba(31, 38, 135, 0.12), inset 0 1px 0 0 rgba(255, 255, 255, 0.9);
    --text-main: #2D3436;
    --text-muted: #636E72;
    --input-bg: rgba(255, 255, 255, 0.6);
    --input-border: rgba(0, 0, 0, 0.08);
    --dropdown-bg: #FFFFFF;
}

/* ================= RESET Y BASE ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background 0.3s, box-shadow 0.3s, color 0.2s, transform 0.2s;
}

body {
    font-family: var(--font);
    background: var(--bg-gradient);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('images/bg.webp');
    background-size: cover;
    background-position: bottom center;
    background-repeat: no-repeat;
    opacity: 0.1;
    z-index: -1;
    pointer-events: none;
}

button,
input {
    font-family: inherit;
    outline: none;
}

.hidden {
    display: none !important;
}

/* ================= UTILIDADES ================= */
.glass-panel {
    background-image: var(--internal-glow-1), var(--internal-glow-2), linear-gradient(var(--glass-bg-base), var(--glass-bg-base));
    background-size: 100% 100%, 100% 100%, cover;
    background-position: center;
    background-repeat: no-repeat;
    backdrop-filter: blur(20px) saturate(110%);
    -webkit-backdrop-filter: blur(20px) saturate(110%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--shadow-glass);
}

.item-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--shadow-glass);
}

/* ================= LOGIN ================= */
.center-box {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    text-align: center;
}

.icon-glow {
    font-size: 3.5rem;
    color: var(--primary);
    filter: drop-shadow(0 0 15px rgba(108, 92, 231, 0.4));
    margin-bottom: 15px;
}

#auth-title {
    font-size: 1.8rem;
    margin-bottom: 5px;
    font-weight: 700;
}

#auth-desc {
    color: var(--text-muted);
    margin-bottom: 30px;
    font-weight: 500;
}

.input-group {
    position: relative;
    display: flex;
    width: 100%;
}

.input-group input {
    width: 100%;
    padding: 16px 55px 16px 20px;
    font-size: 1rem;
}

.btn-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--primary-glow-box);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    transform: translateY(-50%) scale(1.1);
}

/* ================= LAYOUT ================= */
.app-layout {
    width: 98%;
    max-width: 1920px;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-self: flex-start;
}

header.header-bar {
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

header.header-bar::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--primary), var(--accent), #6c5ce7, var(--primary));
    background-size: 300% 100%;
    opacity: 0.22;
    animation: flowGlow 15s ease-in-out infinite;
    z-index: -2;
    pointer-events: none;
}

header.header-bar::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('images/techp.webp');
    background-repeat: repeat;
    background-size: 200px;
    opacity: 0.3;
    z-index: -1;
    pointer-events: none;
    mix-blend-mode: multiply;
}

@keyframes flowGlow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    color: var(--primary);
    filter: drop-shadow(0 0 8px rgba(108, 92, 231, 0.5));
}

.btn-small {
    background: rgba(var(--primary), 0.1);
    color: var(--text-muted);
    border: 1px solid var(--input-border);
    padding: 8px 18px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-small:hover {
    background: var(--input-bg);
    color: var(--primary);
    border-color: var(--primary);
}

/* ================= GRID PRINCIPAL ================= */
.main-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    align-items: start;
}

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

/* ================= FORMS ================= */
.create-panel {
    padding: 30px;
    position: sticky;
    top: 20px;
    z-index: 50;
}

.panel-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--glass-border);
}

.panel-header h3 {
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
}

.form-grid-vertical {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-container {
    position: relative;
    z-index: 1;
}

input {
    width: 100%;
    padding: 14px 18px;
    border-radius: 16px;
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--input-border);
    font-size: 0.9rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

input:focus {
    border-color: var(--primary);
    background: rgba(var(--primary), 0.05);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05), 0 0 0 3px rgba(108, 92, 231, 0.2);
}

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

.split-inputs {
    display: flex;
    gap: 10px;
}

.form-fields-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* --- DROPDOWN --- */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    padding: 0 18px;
    cursor: pointer;
    height: 50px;
    font-size: 1rem;
    border-radius: 16px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-main);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.custom-select-trigger span {
    margin-left: 10px;
    font-weight: 500;
    font-size: 0.9rem;
}

.custom-options {
    position: absolute;
    top: 105%;
    left: 0;
    width: 100%;
    background: var(--dropdown-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999;
}

.custom-options::-webkit-scrollbar {
    width: 5px;
}

.custom-options::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.custom-select.open .custom-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-option {
    padding: 10px 18px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--input-border);
}

.custom-option:last-child {
    border-bottom: none;
}

.custom-option:hover {
    background: var(--primary);
    color: white;
}

.btn-primary {
    width: 100%;
    padding: 15px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: var(--primary-glow-box);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -5px rgba(108, 92, 231, 0.6);
}

/* ================= GRID DE ITEMS ================= */
.items-section {
    width: 100%;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    padding: 6px;
    background: var(--input-bg);
    border-radius: 20px;
    width: fit-content;
    border: 1px solid var(--input-border);
}

.tab {
    padding: 8px 24px;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
}

.tab.active {
    background: var(--bg-main);
    color: var(--primary);
    box-shadow: var(--shadow-glass);
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.item-card {
    padding: 25px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-icon {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: var(--input-bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    box-shadow: inset 0 0 0 1px var(--input-border);
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.1));
}

.card-title {
    font-weight: 700;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Botones en Cards */
.card-actions {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
}

.icon-btn-small {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.delete-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.delete-btn:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.15);
}

.edit-btn {
    background: rgba(var(--primary), 0.15);
    color: var(--primary);
}

.edit-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.15);
}

.secret-row {
    background: var(--input-bg);
    padding: 12px 15px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-muted);
    border: 1px solid var(--input-border);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.blur-secret {
    filter: blur(6px);
    cursor: pointer;
    transition: 0.4s;
    user-select: none;
}

.blur-secret:hover {
    filter: blur(0);
    color: var(--text-main);
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    font-size: 1rem;
}

.action-btn:hover {
    color: var(--primary);
    transform: scale(1.2);
}

/* ================= MODAL DE EDICIÓN (NUEVO) ================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    width: 90%;
    max-width: 450px;
    padding: 30px;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
}

.close-modal-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.close-modal-btn:hover {
    color: #ef4444;
    transform: rotate(90deg);
}

/* ================= EXTRAS ================= */
.theme-toggle {
    position: fixed;
    bottom: 35px;
    right: 35px;
    z-index: 2000;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: none;
    background: var(--glass-bg-base);
    color: var(--text-main);
    box-shadow: var(--shadow-glass);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    font-size: 1.4rem;
    backdrop-filter: blur(20px);
}

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 35px;
    height: 35px;
    animation: spin 0.8s linear infinite;
    margin: 25px auto 0;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ================= SCROLLBAR GLOBAL ================= */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}