:root {
    --primary: #0ea5e9;
    --primary-dark: #0369a1;
    --primary-light: #e0f2fe;
    --bg-dark: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-purple: #8b5cf6;
    --accent-emerald: #10b981;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(80px);
}

.blob {
    position: absolute;
    width: 40vw;
    height: 40vw;
    border-radius: 50%;
    opacity: 0.2;
    animation: move 20s infinite alternate;
}

.blob-1 {
    background: var(--primary);
    top: -10%;
    left: -10%;
}

.blob-2 {
    background: var(--accent-purple);
    bottom: -10%;
    right: -10%;
    animation-delay: -5s;
}

.blob-3 {
    background: var(--accent-emerald);
    top: 40%;
    left: 40%;
    width: 30vw;
    height: 30vw;
    animation-delay: -10s;
}

@keyframes move {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(100px, 100px) scale(1.2); }
}

/* Login Screen */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h2 {
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.error-msg {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 12px;
    font-weight: 600;
}

/* App Layout */
.app-container {
    width: 100%;
    max-width: 1100px;
    padding: 40px 20px;
}

.app-container.hidden {
    display: none;
}

.hero {
    text-align: center;
    margin-bottom: 50px;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}

.logo svg {
    width: 28px;
    height: 28px;
}

h1 {
    font-family: 'Syne', sans-serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(to bottom right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
    margin-bottom: 30px;
}

/* Tabs */
.tabs {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 100px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.tab-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Grid Layout */
.generator-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 30px;
}

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

/* Glassmorphism Cards */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

h2, h3 {
    font-family: 'Syne', sans-serif;
    margin-bottom: 24px;
    font-size: 1.4rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

input, select, textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px 16px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    resize: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.btn-primary {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 16px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
    box-shadow: 0 10px 20px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(14, 165, 233, 0.4);
}

.btn-primary svg {
    width: 20px;
    height: 20px;
}

/* Dynamic Rows Management */
.dynamic-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.limit-row-input {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.btn-add-row {
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--glass-border);
    color: var(--primary);
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-add-row:hover {
    background: rgba(14, 165, 233, 0.05);
    border-color: var(--primary);
}

.btn-remove-row {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: #ef4444;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
}

.btn-remove-row:hover {
    background: #ef4444;
    color: white;
}

/* Result Panel */
.result-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-card {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    width: 60px;
    height: 60px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.hidden {
    display: none !important;
}

/* License Display */
.license-display {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.status-badge {
    position: absolute;
    top: 24px;
    right: 24px;
    background: var(--accent-emerald);
    color: white;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 800;
}

.client-name {
    color: var(--text-muted);
    margin-top: -16px;
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.key-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
}

.key-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.key-value {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
    word-break: break-all;
}

#copyBtn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

#copyBtn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

#copyBtn svg {
    width: 20px;
    height: 20px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item .label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 700;
}

.detail-item .value {
    font-weight: 700;
    font-size: 0.9rem;
}

.btn-secondary {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Limits Panel */
.limits-info h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.limit-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.limit-preview-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.limit-row strong {
    color: var(--primary);
}

.modules-container {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chip {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Plan Colors */
.plan-basico { background: rgba(14, 165, 233, 0.15); color: #0ea5e9; }
.plan-superior { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.plan-avanzado { background: rgba(16, 185, 129, 0.15); color: #10b981; }

/* App Items List */
.app-items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.app-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.app-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.app-item-info h4 {
    margin: 0 0 4px 0;
    font-size: 1rem;
}

.app-item-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.app-item-actions {
    display: flex;
    gap: 8px;
}

.btn-edit {
    background: rgba(14, 165, 233, 0.1);
    border: none;
    color: var(--primary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: #ef4444;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: #ef4444;
    color: white;
}

.empty-list {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-style: italic;
    font-size: 0.9rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

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

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

/* Fix select visibility */
select, option { background-color: #1e293b !important; color: white !important; }
input, textarea { background-color: #1e293b !important; }

/* Tier Configuration Panel */
.divider {
    border: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--glass-border), transparent);
    margin: 30px 0;
}

.tier-config-panel {
    animation: fadeIn 0.4s ease-out;
}

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

.tier-header h3 {
    margin-bottom: 0;
    font-size: 1.1rem;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.w-full {
    width: 100%;
}

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

.panel-header h3 {
    margin-bottom: 0;
}

/* Fix for history list deletion */
.btn-delete-license, .btn-delete-app {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: #ef4444;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

/* Professional Tier Editor Styles */
.tier-subheader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.info-tip {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.modules-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.module-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.module-checkbox-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.module-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.module-checkbox-item span {
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-outline {
    background: transparent;
    border-style: dashed;
    color: var(--text-muted);
}

.btn-outline:hover {
    border-style: solid;
    border-color: var(--primary);
    color: var(--primary);
}

.w-full {
    width: 100%;
}

/* Full Panel & Grid */
.full-panel {
    grid-column: 1 / -1;
}

.panel-title h2 { margin-bottom: 4px; }
.panel-title p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0; }

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    height: fit-content;
}

.app-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.app-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.app-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.app-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.app-card-icon {
    width: 48px;
    height: 48px;
    background: rgba(14, 165, 233, 0.1);
    color: var(--primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-card-info h4 {
    font-size: 1.2rem;
    margin: 12px 0 4px 0;
    font-family: 'Syne', sans-serif;
}

.app-card-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.app-card-stats {
    display: flex;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--glass-border);
}

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

.stat-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.stat-value { font-size: 0.9rem; font-weight: 700; color: var(--primary); }

/* Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}

.modal-container {
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
    animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

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

.modal-identity {
    display: flex;
    align-items: center;
    gap: 16px;
}

.modal-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.modal-header h2 { margin: 0; font-size: 1.25rem; }
.modal-header p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.btn-close-modal:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.modal-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    margin: 20px 32px 0 32px;
    border-radius: 12px;
}

.studio-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.studio-tab-btn.active {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

.studio-tab-content { display: none; }
.studio-tab-content.active { display: block; animation: fadeIn 0.3s; }

.modal-footer {
    padding: 24px 32px;
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.1);
}

.btn-delete-app-inline {
    background: transparent;
    border: none;
    color: #ef4444;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s;
}

.btn-delete-app-inline:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.1);
}
