:root {
    --bg-main: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-hover: rgba(51, 65, 85, 0.8);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(15, 23, 42, 0.6);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --animation-speed: 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    overflow: hidden;
    height: 100vh;
}

/* Scrollbar Modern */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: all 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    flex: 1;
    padding: 12px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none !important;
    border-radius: 8px;
    transition: all 0.2s;
    margin-bottom: 4px;
    font-weight: 500;
}

.menu-item:hover,
.menu-item.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.menu-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.menu-item.logout {
    margin-top: auto;
    color: #f87171;
}

.menu-item.logout:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 70px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
}

.search-wrapper {
    position: relative;
    width: 400px;
}

.search-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 10px 10px 40px;
    color: white;
    outline: none;
    transition: all 0.2s;
}

.search-input:focus {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    text-align: right;
}

.user-info .name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-info .role {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Dashboard View */
.view-container {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 24px;
}

.scripts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    align-content: start;
}

/* Script Card */
.script-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all var(--animation-speed) cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.4s ease-out backwards;
}

.script-card:nth-child(even) {
    animation-delay: 0.1s;
}

.script-card:nth-child(3n) {
    animation-delay: 0.2s;
}

.script-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.script-card:hover {
    transform: translateY(-5px);
    border-color: rgba(99, 102, 241, 0.4);
    background: var(--bg-hover);
    box-shadow: var(--shadow-lg);
}

.script-card:hover::after {
    opacity: 1;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.card-content h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.card-content p {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.card-footer {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
}

.btn-execute {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-execute:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

/* Log Panel Modern */
.log-panel-modern {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - 134px);
    position: sticky;
    top: 0;
}

.log-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(30, 41, 59, 0.5);
}

.log-panel-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.log-actions-group {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    transition: all 0.2s;
    cursor: pointer;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-icon.danger:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.4);
}

#logs-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Modals Modern */
.modal-content {
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: white;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 24px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 20px 24px;
}

.form-control {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: white;
    border-radius: 10px;
    padding: 12px;
}

.form-control:focus {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    color: white;
    box-shadow: none;
}

/* Log Entry Styling */
.log-entry {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.log-header {
    padding: 12px 16px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.log-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.log-status {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 12px;
    text-transform: uppercase;
}

.status-running {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    animation: pulse 1.5s infinite;
}

.status-completed {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.status-error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.log-line {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    padding: 4px 0;
    line-height: 1.5;
}

.log-line:last-child {
    border-bottom: none;
}

.log-line.log-info {
    color: #e2e8f0;
}

.log-line.log-success {
    color: #34d399;
}

.log-line.log-error {
    color: #f87171;
}

.log-line.log-warning {
    color: #fbbf24;
}

.log-timestamp-inline {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-right: 8px;
    user-select: none;
}

.log-level {
    font-size: 0.7rem;
    padding: 1px 4px;
    border-radius: 3px;
    margin-right: 8px;
    text-transform: uppercase;
    font-weight: 700;
}

.level-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.level-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.level-error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.level-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

/* Metadato de tiempo de ejecución en el header del log */
.log-execution-time {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 12px;
    padding: 2px 8px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 4px;
    font-weight: 500;
}

.log-execution-time[data-relative-time*="hora"],
.log-execution-time[data-relative-time*="minuto"],
.log-execution-time[data-relative-time="ahora mismo"] {
    color: #34d399;
    background: rgba(52, 211, 153, 0.1);
}

.log-execution-time[data-relative-time*="día"] {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
}

.log-execution-time[data-relative-time*="semana"],
.log-execution-time[data-relative-time*="mes"] {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.log-content {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    max-height: 250px;
    overflow-y: auto;
}

/* Button colors mapping */
.bg-primary {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.bg-success {
    background-color: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.bg-danger {
    background-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.bg-info {
    background-color: rgba(6, 182, 212, 0.2);
    color: #22d3ee;
}

.bg-warning {
    background-color: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.bg-purple {
    background-color: rgba(168, 85, 247, 0.2);
    color: #c084fc;
}

.bg-zapote {
    background-color: rgba(249, 115, 22, 0.2);
    color: #fb923c;
}

.bg-tinto {
    background-color: rgba(185, 28, 28, 0.2);
    color: #f87171;
}

.bg-forbes {
    background-color: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.bg-azules {
    background-color: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
}

.bg-amarillo {
    background-color: rgba(234, 179, 8, 0.2);
    color: #facc15;
}

/* Responsive */
@media (max-width: 1200px) {
    .view-container {
        grid-template-columns: 1fr;
    }

    .log-panel-modern {
        height: 400px;
        position: relative;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 80px;
    }

    .sidebar-header h2,
    .menu-item span,
    .user-info {
        display: none;
    }

    .search-wrapper {
        width: 200px;
    }
}