/**
 * Ciberecus Systems México - Estilos Principales
 * CSS modular, mobile-first, sin frameworks pesados.
 */

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font-family, 'Segoe UI', system-ui, sans-serif);
    line-height: 1.6;
    color: #212529;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.cb-widget {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1050;
}

.cb-toggle {
    width: 54px;
    height: 54px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.cb-panel {
    width: 340px;
    max-width: calc(100vw - 36px);
    height: 460px;
    max-height: calc(100vh - 120px);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
}

.cb-header {
    background: var(--primary-color, #0d6efd);
    color: #fff;
    padding: 12px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cb-title {
    font-weight: 700;
}

.cb-body {
    padding: 12px;
    overflow: auto;
    flex: 1;
    background: #f8f9fa;
}

.cb-footer {
    padding: 12px;
    border-top: 1px solid #dee2e6;
    background: #fff;
}

.cb-msg {
    display: flex;
    margin-bottom: 10px;
}

.cb-msg-user {
    justify-content: flex-end;
}

.cb-msg-bot {
    justify-content: flex-start;
}

.cb-bubble {
    max-width: 82%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: .95rem;
    line-height: 1.35;
}

.cb-msg-user .cb-bubble {
    background: var(--primary-color, #0d6efd);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.cb-msg-bot .cb-bubble {
    background: #fff;
    border: 1px solid #dee2e6;
    color: #212529;
    border-bottom-left-radius: 4px;
}

.cb-bubble a {
    color: inherit;
    text-decoration: underline;
}

/* ===== UTILITIES ===== */
.bg-primary-custom { background-color: var(--primary-color, #0d6efd) !important; }
.text-primary-custom { color: var(--primary-color, #0d6efd) !important; }

/* ===== NAVBAR ===== */
.navbar-brand { font-size: 1.4rem; }
.navbar .nav-link { transition: color .2s; }
.navbar .nav-link:hover, .navbar .nav-link.active { color: #0dcaf0 !important; }

/* ===== HERO SECTION ===== */
.hero-section {
    background: linear-gradient(135deg, #0d1b2a 0%, #1b263b 60%, #415a77 100%);
    color: #fff;
    padding: 80px 0;
    position: relative;
    overflow: hidden;
}
.hero-section::before {
    content: '';
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: .4;
}
.hero-content { position: relative; z-index: 1; }

/* ===== HERO SLIDER ===== */
.hero-slider {
    position: relative;
    width: 100%;
    height: 500px;
    overflow: hidden;
    background: #0d1b2a;
}
.slider-track {
    position: relative;
    width: 100%;
    height: 100%;
}
.slider-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    z-index: 1;
}
.slider-slide.active {
    opacity: 1;
    z-index: 2;
}
.slider-bg {
    position: absolute;
    inset: 0;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}
.slider-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, rgba(13,27,42,0.85) 0%, rgba(13,27,42,0.4) 100%);
}
.slider-content {
    position: relative;
    z-index: 3;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #fff;
    padding: 0 1rem;
}
.slider-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    animation: fadeInUp 0.8s ease-out both;
}
.slider-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    max-width: 600px;
    text-shadow: 0 1px 5px rgba(0,0,0,0.5);
    animation: fadeInUp 0.8s ease-out 0.2s both;
}
.slider-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    gap: 10px;
}
.slider-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.6);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s;
}
.slider-dot.active {
    background: #fff;
    border-color: #fff;
}
.slider-dot:hover {
    border-color: #fff;
}

.slider-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(0,0,0,0.35);
    border: 2px solid rgba(255,255,255,0.5);
    color: #fff;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    font-size: 1.25rem;
    line-height: 1;
}
.slider-arrow:hover {
    background: rgba(0,0,0,0.65);
    border-color: #fff;
}
.slider-arrow-prev { left: 18px; }
.slider-arrow-next { right: 18px; }
@media (max-width: 576px) {
    .slider-arrow { width: 36px; height: 36px; font-size: 1rem; }
    .slider-arrow-prev { left: 8px; }
    .slider-arrow-next { right: 8px; }
}

.slider-btn {
    max-width: 100px;
    color: #fff;
    background: transparent;
    padding: 0.5rem 1rem;
    transition: opacity .2s;
}
.slider-btn:hover {
    opacity: 0.7;
    color: #fff;
}

@media (max-width: 768px) {
    .hero-slider { height: 380px; }
    .slider-title { font-size: 2rem; }
    .slider-subtitle { font-size: 1rem; }
}

/* ===== TECH NEWS SECTION ===== */
.tech-news-section {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
    position: relative;
    overflow: hidden;
}
.tech-news-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.025'%3E%3Cpath d='M50 50c0-5.523 4.477-10 10-10s10 4.477 10 10-4.477 10-10 10-10-4.477-10-10zM10 10c0-5.523 4.477-10 10-10s10 4.477 10 10-4.477 10-10 10S10 15.523 10 10z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}
.tech-news-card {
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    overflow: hidden;
    transition: transform .35s cubic-bezier(.34,1.56,.64,1), box-shadow .35s ease, background .35s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.tech-news-card:hover {
    transform: translateY(-8px);
    background: rgba(255,255,255,0.1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
.tech-news-img-wrap {
    position: relative;
    height: 180px;
    overflow: hidden;
}
.tech-news-img {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform .6s cubic-bezier(.25,.46,.45,.94);
}
.tech-news-card:hover .tech-news-img {
    transform: scale(1.08);
}
.tech-news-img-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(15,23,42,0.8) 0%, transparent 60%);
    pointer-events: none;
}
.tech-news-tag {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(14,165,233,0.9);
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.tech-news-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.tech-news-title {
    color: #f1f5f9;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: .5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tech-news-desc {
    color: #94a3b8;
    font-size: .88rem;
    line-height: 1.55;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}
.tech-news-meta {
    color: #64748b;
    font-size: .8rem;
}

/* ===== ARTICLE MODAL STYLES ===== */
.article-hero-img {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.article-title {
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: .75rem;
}
.article-meta-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.article-meta {
    color: #94a3b8;
    font-size: .85rem;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.article-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(148,163,184,0.3), transparent);
    margin: 1.25rem 0;
}
.article-body-render {
    color: #e2e8f0;
    font-size: 1rem;
    line-height: 1.8;
}
.article-body-render p {
    margin-bottom: 1.1rem;
    color: #e2e8f0;
}
.article-body-render a {
    color: #38bdf8;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color .2s;
}
.article-body-render a:hover {
    color: #7dd3fc;
}
.article-body-render img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 1.25rem 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    display: block;
}
.article-body-render h1,
.article-body-render h2,
.article-body-render h3,
.article-body-render h4 {
    color: #f8fafc;
    margin-top: 2rem;
    margin-bottom: .75rem;
    font-weight: 700;
    line-height: 1.3;
}
.article-body-render h1 { font-size: 1.5rem; }
.article-body-render h2 { font-size: 1.3rem; }
.article-body-render h3 { font-size: 1.15rem; }
.article-body-render h4 { font-size: 1.05rem; }
.article-body-render ul,
.article-body-render ol {
    padding-left: 1.5rem;
    margin-bottom: 1.1rem;
}
.article-body-render li {
    margin-bottom: .35rem;
}
.article-body-render blockquote {
    border-left: 4px solid #38bdf8;
    background: rgba(56,189,248,0.08);
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    border-radius: 0 8px 8px 0;
    color: #cbd5e1;
    font-style: italic;
}
.article-body-render blockquote p:last-child {
    margin-bottom: 0;
}
.article-body-render pre {
    background: #0f172a;
    border: 1px solid rgba(148,163,184,0.15);
    padding: 1rem;
    border-radius: 10px;
    overflow-x: auto;
    margin: 1.25rem 0;
    font-size: .9rem;
}
.article-body-render code {
    background: #1e293b;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: .9em;
    color: #7dd3fc;
}
.article-body-render iframe,
.article-body-render embed {
    max-width: 100%;
    border-radius: 10px;
    margin: 1.25rem 0;
}
.article-body-render figure {
    margin: 1.25rem 0;
}
.article-body-render figcaption {
    color: #94a3b8;
    font-size: .85rem;
    text-align: center;
    margin-top: .5rem;
}
.article-body-render table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    border-radius: 8px;
    overflow: hidden;
}
.article-body-render th,
.article-body-render td {
    padding: .75rem 1rem;
    border: 1px solid rgba(148,163,184,0.15);
}
.article-body-render th {
    background: rgba(56,189,248,0.1);
    color: #38bdf8;
    font-weight: 600;
}
.article-body-render td {
    background: rgba(15,23,42,0.4);
}
.article-body-render strong {
    color: #f8fafc;
    font-weight: 700;
}
.article-body-render em {
    color: #cbd5e1;
}

@media (max-width: 767.98px) {
    .tech-news-img-wrap { height: 160px; }
    .tech-news-title { font-size: .95rem; }
    .article-title { font-size: 1.25rem; }
    .article-hero-img { max-height: 200px; }
}

/* ===== CARDS ===== */
.card { transition: transform .2s, box-shadow .2s; border: none; }
.card-hover:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(0,0,0,.12); }

/* ===== SERVICIOS DESTACADOS ===== */
.service-card {
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(13, 27, 42, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.6);
    transition: transform .4s cubic-bezier(.34,1.56,.64,1), box-shadow .4s ease, border-color .3s ease;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}
.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    transition: left 0.7s ease;
    pointer-events: none;
    z-index: 3;
}
.service-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 24px 64px rgba(13, 27, 42, 0.15);
    border-color: rgba(13, 110, 253, 0.2);
}
.service-card:hover::before {
    left: 100%;
}
.service-card .service-img-wrap {
    position: relative;
    height: 200px;
    overflow: hidden;
}
.service-card .service-img {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform .8s cubic-bezier(.25,.46,.45,.94);
}
.service-card:hover .service-img {
    transform: scale(1.15);
}
.service-card .service-img-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(13,27,42,0.75) 0%, rgba(13,27,42,0.2) 50%, transparent 100%);
    pointer-events: none;
}
.service-card .service-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.95);
    color: var(--primary-color, #0d6efd);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 2;
}
.service-card .service-icon-float {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(13, 110, 253, 0.25), 0 0 0 4px rgba(13, 110, 253, 0.08);
    z-index: 2;
    font-size: 1.8rem;
    transition: transform .35s cubic-bezier(.34,1.56,.64,1), box-shadow .35s ease;
}
.service-card:hover .service-icon-float {
    transform: translateX(-50%) scale(1.1) rotate(-5deg);
    box-shadow: 0 12px 32px rgba(13, 110, 253, 0.35), 0 0 0 6px rgba(13, 110, 253, 0.12);
}
.service-card .service-body {
    padding: 48px 24px 28px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.service-card .service-number {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary-color, #0d6efd);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    opacity: 0.6;
}
.service-card .service-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: #1a1a2e;
    line-height: 1.3;
    letter-spacing: -0.3px;
}
.service-card .service-desc {
    font-size: 0.95rem;
    color: #6c757d;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}
.service-card .service-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color,#0d6efd) 0%, #0056b3 100%);
    padding: 10px 24px;
    border-radius: 50px;
    text-decoration: none;
    transition: all .3s ease;
    box-shadow: 0 4px 15px rgba(13, 110, 253, 0.3);
    align-self: center;
}
.service-card .service-link i {
    transition: transform .3s ease;
}
.service-card:hover .service-link {
    gap: 12px;
    box-shadow: 0 8px 25px rgba(13, 110, 253, 0.4);
    transform: translateY(-2px);
}
.service-card:hover .service-link i {
    transform: translateX(4px);
}

@media (max-width: 767.98px) {
    .service-card .service-img-wrap { height: 160px; }
    .service-card .service-body { padding: 40px 18px 22px; }
    .service-card .service-title { font-size: 1.1rem; }
}

/* ===== SECTIONS SPACING ===== */
.section-py { padding: 60px 0; }

/* ===== FOOTER ===== */
.site-footer { margin-top: auto; }
.site-footer a { transition: opacity .2s; }
.site-footer a:hover { opacity: 1 !important; }

/* ===== BUTTONS ===== */
.btn { border-radius: .5rem; }
.btn-primary-custom {
    background-color: var(--primary-color, #0d6efd);
    border-color: var(--primary-color, #0d6efd);
    color: #fff;
}

/* ===== ADMIN LAYOUT ===== */
.admin-wrapper { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    left: 0; top: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.admin-sidebar > nav {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}
.admin-sidebar > nav::-webkit-scrollbar { width: 4px; }
.admin-sidebar > nav::-webkit-scrollbar-track { background: transparent; }
.admin-sidebar > nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }
.admin-sidebar .nav-link { border-radius: .375rem; transition: background .2s; }
.admin-sidebar .nav-link:hover { background: rgba(255,255,255,.1); }
.admin-main { margin-left: 260px; flex-grow: 1; padding: 1.5rem; background: #f1f3f5; min-height: 100vh; }

@media (max-width: 991.98px) {
    .admin-sidebar { transform: translateX(-100%); transition: transform .3s; }
    .admin-sidebar.show { transform: translateX(0); }
    .admin-main { margin-left: 0; }
}

/* ===== FORMS ===== */
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color, #0d6efd);
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeInUp .6s ease-out both; }

/* ===== CART BADGE ===== */
.cart-badge {
    position: absolute;
    top: -5px; right: -5px;
    font-size: .65rem;
    padding: .2em .45em;
}

/* ===== BOOK / TOOL GRID ===== */
.book-card img, .tool-card img {
    height: 220px; object-fit: cover; width: 100%;
}
a:has(.tool-card) { color: inherit; }
a:has(.tool-card):hover { color: inherit; }

/* ===== LAZY LOAD ===== */
img[loading="lazy"] { opacity: 0; transition: opacity .4s ease; }
img[loading="lazy"].loaded { opacity: 1; }
img[loading="lazy"][src]:not([src=""]) { animation: lazyFallback 0s .8s forwards; }
@keyframes lazyFallback { to { opacity: 1; } }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ===== RESPONSIVE IMAGES IN CONTENT ===== */
.dynamic-content img, .ql-editor img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 15px;
}

/* ===== QUILL IMAGE TOOLBAR ===== */
.ql-image-toolbar {
    position: absolute;
    display: none;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    padding: 4px 6px;
    z-index: 2000;
    gap: 4px;
}
.ql-image-toolbar button {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    color: #495057;
}
.ql-image-toolbar button:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* ===== QUILL TABLE TOOLBAR ===== */
.ql-table-toolbar {
    position: absolute;
    display: none;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    padding: 4px 6px;
    z-index: 2000;
    gap: 4px;
}
.ql-table-toolbar button {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    color: #495057;
}
.ql-table-toolbar button:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}
