:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary: #64748b;

    --bg-body: #f1f5f9;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #f8fafc;

    --border-color: #e2e8f0;
    --input-bg: #f8fafc;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 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);

    --radius: 0.5rem;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Login Page */
.login-page {
    background-color: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    max-width: 150px;
    height: auto;
    margin-bottom: 1.5rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 50;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.sidebar-logo {
    max-width: 120px;
    height: auto;
    margin-bottom: 1rem;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    opacity: 0.9;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    display: block;
    padding: 0.75rem 1.5rem;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.95rem;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
    border-left-color: var(--primary);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-logout {
    display: block;
    text-align: center;
    padding: 0.75rem;
    color: #ef4444;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius);
    transition: all 0.2s;
}

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

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    max-width: 100%;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.top-bar h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
}

.user-info {
    font-size: 0.875rem;
    color: var(--text-muted);
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    box-shadow: var(--shadow-sm);
}

.content-wrapper {
    max-width: 1000px;
    margin: 0 auto;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8fafc;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-main);
}

/* Shared styles for all inputs */
.form-control,
.apartado-name,
.apartado-titulo,
.apartado-parent,
.apartado-enlace,
.servicio-name {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--bg-card);
    background-clip: padding-box;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.apartado-name:focus,
.apartado-titulo:focus,
.apartado-parent:focus,
.apartado-enlace:focus,
.servicio-name:focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-text {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.form-check input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 0.25rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.form-check label {
    margin-bottom: 0;
    cursor: pointer;
    font-size: 1rem;
}

/* Dynamic Sections Styling */
.apartado-item,
.servicio-item {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    position: relative;
}

.btn-remove {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #fee2e2;
    color: #ef4444;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: #fecaca;
    transform: scale(1.1);
}

.servicio-item {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
}

.servicio-item .servicio-name {
    flex: 1;
}

.servicio-item .btn-remove {
    position: static;
    margin-left: auto;
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}

.col-md-6,
.col-md-4 {
    position: relative;
    width: 100%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
}

@media (min-width: 768px) {
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

/* File Upload */
.file-upload-wrapper {
    background: #f8fafc;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px dashed var(--border-color);
    text-align: center;
}

.file-preview {
    margin-top: 0.5rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview img {
    max-height: 80px;
    max-width: 100%;
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
}

/* Color Pickers */
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.color-item label {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.color-input-group {
    display: flex;
    gap: 0.5rem;
}

.color-input-group input[type="color"] {
    width: 40px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
}

.color-input-group input[type="text"] {
    flex: 1;
    padding: 0.375rem 0.75rem;
    font-family: monospace;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 1rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.radio-option:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.radio-option input[type="radio"] {
    accent-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-block;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
    user-select: none;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: var(--radius);
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    border: 1px solid transparent;
    letter-spacing: 0.025em;
}

.btn-primary {
    color: #fff;
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2), 0 2px 4px -1px rgba(37, 99, 235, 0.1);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3), 0 4px 6px -2px rgba(37, 99, 235, 0.15);
}

.btn-secondary {
    color: #fff;
    background-color: var(--secondary);
    border-color: var(--secondary);
}

.btn-outline {
    color: var(--primary);
    background-color: transparent;
    border-color: var(--primary);
}

.btn-outline:hover {
    color: #fff;
    background-color: var(--primary);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.action-bar {
    margin-top: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    text-align: center;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-error {
    color: #991b1b;
    background-color: #fee2e2;
    border-color: #fecaca;
}

/* Logs Console */
.logs-console {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: var(--radius);
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    height: 400px;
    overflow-y: auto;
    line-height: 1.6;
    white-space: pre-wrap;
}

.log-line {
    margin-bottom: 0.25rem;
    padding: 0.25rem 0;
}

.log-line.log-info {
    color: #94a3b8;
}

.log-line.log-success {
    color: #4ade80;
    font-weight: 500;
}

.log-line.log-error {
    color: #f87171;
    font-weight: 500;
}

.log-line.log-warning {
    color: #fbbf24;
    font-weight: 500;
}

.progress-bar-container {
    height: 0.5rem;
    background-color: #e2e8f0;
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

/* Result Modal */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.result-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
        /* Mobile menu implementation needed if requested */
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .action-bar {
        position: static;
        margin-top: 2rem;
    }
}