/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #5288c1;
    --accent-light: #6ab3f3;
    --border: #333333;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Layout ===== */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-light);
    font-weight: 600;
    font-size: 18px;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent);
    color: white;
}

.header-actions {
    margin-left: auto;
    display: flex;
    gap: 12px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--accent-light);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ===== Main Layout ===== */
.main {
    display: flex;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    padding: 24px;
    gap: 24px;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: calc(100vh - 112px);
    overflow-y: auto;
    padding-right: 8px;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.sidebar-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.section-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ===== Color Inputs ===== */
.color-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.color-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.color-item label {
    font-size: 13px;
    color: var(--text-secondary);
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    padding: 4px 8px 4px 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.color-input-wrapper input[type="color"] {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    background: transparent;
}

.color-input-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input-wrapper input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-hex {
    width: 70px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 12px;
    font-family: monospace;
    text-transform: uppercase;
}

.color-hex:focus {
    outline: none;
}

/* ===== Presets ===== */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

.presets-grid::-webkit-scrollbar {
    width: 6px;
}

.presets-grid::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.presets-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.presets-grid::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.preset-btn:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.preset-colors {
    display: flex;
    gap: 4px;
}

.preset-colors span {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.1);
}

.preset-name {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== Wallpaper ===== */
.wallpaper-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wallpaper-preview {
    height: 100px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px dashed var(--border);
}

.wallpaper-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wallpaper-placeholder {
    color: var(--text-muted);
    font-size: 13px;
}

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

/* ===== Bubble Options ===== */
.bubble-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== Platform Tabs ===== */
.platform-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.platform-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.platform-tab:hover {
    color: var(--text-primary);
}

.platform-tab.active {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.advanced-colors {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== Preview Container ===== */
.preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.preview-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.preview-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.preview-tab:hover {
    color: var(--text-primary);
}

.preview-tab.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.device-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.device-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.device-btn:hover {
    color: var(--text-primary);
}

.device-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ===== Preview Wrapper ===== */
.preview-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
    min-height: 500px;
}

.preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Desktop Preview ===== */
.desktop-preview {
    max-width: 900px;
    width: 100%;
}

.tg-app {
    display: flex;
    width: 100%;
    height: 500px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

/* Telegram Sidebar */
.tg-sidebar {
    width: 280px;
    background: var(--tg-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--tg-border);
}

.tg-header {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--tg-border);
    background: var(--tg-header-bg);
}

.tg-menu-btn {
    background: transparent;
    border: none;
    color: var(--tg-icon);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
}

.tg-menu-btn:hover {
    background: var(--tg-hover);
}

.tg-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--tg-surface);
    border-radius: 20px;
    color: var(--tg-text-muted);
    font-size: 13px;
}

.tg-chat-list {
    flex: 1;
    overflow-y: auto;
}

.tg-chat-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 12px;
    cursor: pointer;
    position: relative;
}

.tg-chat-item:hover {
    background: var(--tg-hover);
}

.tg-chat-item.active {
    background: var(--tg-active);
}

.tg-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.tg-avatar.small {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.tg-chat-info {
    flex: 1;
    min-width: 0;
}

.tg-chat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.tg-chat-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--tg-text);
}

.tg-chat-item.active .tg-chat-name {
    color: var(--tg-active-text);
}

.tg-chat-time {
    font-size: 12px;
    color: var(--tg-text-muted);
}

.tg-chat-item.active .tg-chat-time {
    color: var(--tg-active-text);
    opacity: 0.8;
}

.tg-chat-preview {
    font-size: 13px;
    color: var(--tg-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tg-chat-item.active .tg-chat-preview {
    color: var(--tg-active-text);
    opacity: 0.8;
}

.tg-sender {
    color: var(--tg-accent);
}

.tg-unread {
    position: absolute;
    right: 12px;
    bottom: 10px;
    background: var(--tg-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* Telegram Main Chat */
.tg-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--tg-bg);
}

.tg-chat-header {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--tg-border);
    background: var(--tg-header-bg);
}

.tg-chat-header-info {
    flex: 1;
}

.tg-chat-header-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--tg-text);
    display: block;
}

.tg-chat-header-status {
    font-size: 12px;
    color: var(--tg-text-muted);
}

.tg-chat-header-actions {
    display: flex;
    gap: 4px;
}

.tg-icon-btn {
    background: transparent;
    border: none;
    color: var(--tg-icon);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
}

.tg-icon-btn:hover {
    background: var(--tg-hover);
}

/* Messages */
.tg-messages {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    background-size: cover;
    background-position: center;
}

.tg-date-divider {
    text-align: center;
    margin: 8px 0;
}

.tg-date-divider span {
    background: var(--tg-service-bg);
    color: var(--tg-service-text);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
}

.tg-message {
    display: flex;
    max-width: 70%;
}

.tg-message.incoming {
    align-self: flex-start;
}

.tg-message.outgoing {
    align-self: flex-end;
}

.tg-message-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    position: relative;
}

.tg-message.incoming .tg-message-bubble {
    background: var(--tg-msg-in);
    border-bottom-left-radius: 4px;
}

.tg-message.outgoing .tg-message-bubble {
    background: var(--tg-msg-out);
    border-bottom-right-radius: 4px;
}

.tg-message-bubble p {
    font-size: 14px;
    color: var(--tg-msg-text);
    margin-bottom: 4px;
    line-height: 1.4;
}

.tg-message-time {
    font-size: 11px;
    color: var(--tg-msg-meta);
    float: right;
    margin-left: 8px;
    margin-top: 4px;
}

.tg-message-check {
    color: var(--tg-check);
    font-size: 12px;
    margin-left: 2px;
}

/* Compose */
.tg-compose {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--tg-header-bg);
    border-top: 1px solid var(--tg-border);
}

.tg-input {
    flex: 1;
    padding: 10px 16px;
    background: var(--tg-surface);
    border-radius: 20px;
    font-size: 14px;
    color: var(--tg-text-muted);
}

.tg-send-btn {
    background: transparent;
    border: none;
    color: var(--tg-primary);
    cursor: pointer;
    padding: 8px;
    display: flex;
}

/* ===== Mobile Preview ===== */
.mobile-preview {
    max-width: 360px;
}

.phone-frame {
    background: #1a1a1a;
    border-radius: 40px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.phone-notch {
    width: 120px;
    height: 24px;
    background: #000;
    margin: 0 auto 8px;
    border-radius: 12px;
}

.tg-mobile-app {
    border-radius: 28px;
    overflow: hidden;
    height: 600px;
    display: flex;
    flex-direction: column;
}

.tg-mobile-header {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--tg-header-bg);
}

.tg-mobile-header-info {
    flex: 1;
}

.tg-mobile-header-name {
    font-weight: 500;
    font-size: 15px;
    color: var(--tg-text);
    display: block;
}

.tg-mobile-header-status {
    font-size: 12px;
    color: var(--tg-text-muted);
}

.tg-mobile-messages {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    background: var(--tg-bg);
    background-size: cover;
    background-position: center;
}

.tg-mobile-compose {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--tg-header-bg);
}

.tg-mobile-input {
    flex: 1;
    padding: 10px 16px;
    background: var(--tg-surface);
    border-radius: 20px;
    font-size: 14px;
    color: var(--tg-text-muted);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* Export Options */
.export-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.export-option:hover {
    border-color: var(--accent);
}

.export-option input {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.export-option input:checked + .checkbox-custom {
    background: var(--accent);
    border-color: var(--accent);
}

.export-option input:checked + .checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 12px;
}

.export-option-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.export-option-name {
    font-weight: 500;
    font-size: 14px;
}

.export-option-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.theme-name-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-name-input label {
    font-size: 13px;
    color: var(--text-secondary);
}

.theme-name-input input {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
}

.theme-name-input input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Import Dropzone */
.import-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: var(--transition);
}

.import-dropzone:hover {
    border-color: var(--accent);
    background: rgba(82, 136, 193, 0.1);
}

.import-dropzone.dragover {
    border-color: var(--accent);
    background: rgba(82, 136, 193, 0.15);
}

.import-dropzone svg {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.import-dropzone p {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.import-dropzone span {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .main {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: none;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .sidebar-section {
        flex: 1;
        min-width: 280px;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 0 16px;
    }
    
    .nav-tabs {
        display: none;
    }
    
    .main {
        padding: 16px;
    }
    
    .desktop-preview {
        display: none;
    }
    
    .mobile-preview {
        display: flex !important;
    }
    
    .device-toggle {
        display: none;
    }
}
