/**
 * Theme Name: MBSM Theme
 * Theme URI: https://mbsm.tn
 * Author: mbsmgroup
 * Version: 1.0.0
 */

/* ===== CSS VARIABLES ===== */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #0f111a;
    --border-color: #30363d;
    --text-main: #c9d1d9;
    --text-muted: #8b949e;
    --text-dim: #484f58;
    --green-primary: #41b883;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "Courier New", Consolas, monospace;
    --nav-height: 64px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    background: var(--bg-primary);
    color: var(--text-main);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ===== APP LAYOUT ===== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--nav-height));
    background: var(--bg-primary);
    overflow: hidden;
}

/* ===== TABS ===== */
.app-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.app-tabs::-webkit-scrollbar { display: none; }

.tab-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}
.tab-button:hover { color: var(--text-main); background: rgba(255,255,255,0.05); }
.tab-button.active {
    background: rgba(65, 184, 132, 0.15);
    border-color: rgba(65, 184, 132, 0.3);
    color: var(--green-primary);
}

/* ===== CONTENT ===== */
.app-content { flex: 1; position: relative; overflow: hidden; }

.tab-content {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
}
.tab-content.active { opacity: 1; visibility: visible; z-index: 1; }

/* ===== HERO ===== */
.hero-section {
    position: relative;
    min-height: 100%;
    padding: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-bg { position: absolute; inset: 0; z-index: 0; }

.hex-grid {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(30deg, rgba(65, 184, 132, 0.03) 12%, transparent 12.5%, transparent 87%, rgba(65, 184, 132, 0.03) 87.5%);
    background-size: 60px 104px;
}

.gradient {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top, rgba(65, 184, 132, 0.1), transparent 60%);
}

.hero-inner { position: relative; z-index: 1; max-width: 800px; width: 100%; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(65, 184, 132, 0.15);
    border: 1px solid rgba(65, 184, 132, 0.3);
    border-radius: 20px;
    font-size: 13px;
    color: var(--green-primary);
    margin-bottom: 24px;
    width: fit-content;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--green-primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.title {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
    line-height: 1.2;
}

.green { color: var(--green-primary); }

.description {
    font-size: 18px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 32px;
    max-width: 600px;
}

.stats {
    display: flex;
    align-items: center;
    gap: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    margin-bottom: 40px;
}
.stat { display: flex; flex-direction: column; }
.num { font-size: 24px; font-weight: 700; }
.label { font-size: 13px; color: var(--text-muted); }
.divider { width: 1px; height: 40px; background: var(--border-color); }

.code-window {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    max-width: 400px;
    margin-top: 24px;
}
.code-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}
.code-header .dot { width: 12px; height: 12px; animation: none; }
.code-header .dot.red { background: #ff5f56; }
.code-header .dot.yellow { background: #ffbd2e; }
.code-header .dot.green { background: #27ca40; }
.code-title { margin-left: 12px; font-size: 13px; color: var(--text-muted); font-family: monospace; }

.code-body {
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
}
.code-body .k { color: #c678dd; }
.code-body .v { color: #61afef; }
.code-body .p { color: #e5c07b; }
.code-body .s { color: #98c379; }
.code-body .b { color: #56b6c2; }

/* ===== PANEL ===== */
.panel { padding: 24px; height: 100%; overflow-y: auto; }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.panel-header h2 { font-size: 24px; font-weight: 700; }
.count {
    font-size: 14px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 4px 12px;
    border-radius: 20px;
}

/* ===== LIST ===== */
.list { display: flex; flex-direction: column; gap: 12px; }

.list-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s;
}
.list-item:hover { border-color: rgba(65, 184, 132, 0.4); transform: translateX(4px); }

.item-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px;
    text-decoration: none;
    color: inherit;
}

.item-thumb {
    width: 80px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-tertiary);
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.no-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.item-body { flex: 1; min-width: 0; }
.item-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.item-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.cat { color: var(--green-primary); font-weight: 500; }
.item-excerpt {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.item-arrow { color: var(--text-muted); opacity: 0; transition: opacity 0.2s; }
.list-item:hover .item-arrow { opacity: 1; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* ===== GRID ===== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.cat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}
.cat-card:hover { border-color: rgba(65, 184, 132, 0.5); background: rgba(65, 184, 132, 0.05); }

.cat-icon {
    width: 40px;
    height: 40px;
    background: rgba(65, 184, 132, 0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--green-primary);
}

.cat-info { flex: 1; }
.cat-name { display: block; font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.cat-count { font-size: 12px; color: var(--text-muted); }
.arrow { color: var(--text-muted); opacity: 0; transition: opacity 0.2s; }
.cat-card:hover .arrow { opacity: 1; }

/* ===== COMING SOON ===== */
.coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    padding: 40px;
}
.coming-soon svg { width: 80px; height: 80px; margin-bottom: 24px; color: var(--text-dim); }
.coming-soon h3 { font-size: 24px; margin-bottom: 12px; }
.coming-soon p { color: var(--text-muted); line-height: 1.6; }

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .app-container { height: auto; min-height: calc(100vh - var(--nav-height)); }
    
    .app-tabs { padding: 8px; gap: 2px; }
    .tab-button { padding: 8px 14px; font-size: 12px; }
    
    .app-content { overflow: visible; }
    .tab-content { position: relative; height: auto; min-height: calc(100vh - 140px); overflow: visible; }
    
    .hero-section { padding: 32px 16px; min-height: auto; }
    .hero-inner { max-width: 100%; }
    .title { font-size: 28px; }
    .description { font-size: 15px; }
    .badge { font-size: 12px; padding: 5px 10px; }
    
    .stats { flex-wrap: wrap; gap: 16px; justify-content: flex-start; }
    .divider { display: none; }
    .code-window { display: none; }
    
    .panel { padding: 16px; overflow-x: hidden; }
    .panel-header { margin-bottom: 16px; padding-bottom: 12px; }
    .panel-header h2 { font-size: 20px; }
    
    .item-link { flex-direction: column; align-items: flex-start; }
    .item-thumb { width: 100%; height: 140px; }
    .item-arrow { display: none; }
    
    .grid { grid-template-columns: 1fr; gap: 8px; }
    .cat-card { padding: 12px; }
    
    .coming-soon { min-height: 300px; padding: 24px 16px; }
    .coming-soon svg { width: 64px; height: 64px; }
    .coming-soon h3 { font-size: 20px; }
    
    body { max-width: 100vw; }
    img { max-width: 100%; height: auto; }
}

@media (max-width: 480px) {
    .title { font-size: 24px; }
    .description { font-size: 14px; }
    .tab-button { padding: 6px 12px; font-size: 11px; }
    .panel { padding: 12px; }
    .item-thumb { height: 140px; }
    .count { font-size: 12px; padding: 2px 8px; }
}

@supports (padding: max(0px)) {
    .app-container {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .app-tabs {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }
    .panel {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}