/* Telegram Bot System - Responsive Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #0088cc;
    --primary-dark: #006699;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #333333;
    --text-muted: #666666;
    --border: #e0e0e0;
    --sidebar-width: 240px;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header .container { display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.25rem; font-weight: 700; color: var(--primary); text-decoration: none; }
.site-header nav a { margin-left: 20px; color: var(--text); font-weight: 500; }
.site-footer { text-align: center; padding: 24px; color: var(--text-muted); font-size: 0.875rem; }

/* Hero */
.hero { text-align: center; padding: 60px 20px; }
.hero h1 { font-size: 2rem; margin-bottom: 12px; }
.subtitle { color: var(--text-muted); margin-bottom: 24px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    padding: 20px 0 60px;
}
.feature-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.feature-card h3 { margin-bottom: 8px; color: var(--primary); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s, opacity 0.2s;
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; text-decoration: none; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c82333; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.875rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: #fff;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,136,204,0.15);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-hint { color: var(--text-muted); font-size: 0.8125rem; margin-top: 8px; }
.form-actions { margin-top: 20px; display: flex; gap: 12px; flex-wrap: wrap; }

.captcha-row { display: flex; gap: 12px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-img { height: 40px; border-radius: 4px; cursor: pointer; border: 1px solid var(--border); }

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card h2 { font-size: 1.125rem; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9375rem; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Admin Layout */
.admin-body { background: var(--bg); }
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: #1a1a2e;
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform 0.3s;
    overflow-y: auto;
}
.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header .logo { color: #fff; font-size: 1.125rem; }
.sidebar-close { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }
.sidebar-nav { padding: 12px 0; }
.sidebar-nav a {
    display: block;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    font-size: 0.9375rem;
}
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-nav .logout-link { margin-top: 20px; border-top: 1px solid rgba(255,255,255,0.1); color: #ff6b6b; }

.admin-main { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; }
.admin-topbar {
    background: var(--card-bg);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}
.admin-topbar h1 { font-size: 1.125rem; flex: 1; }
.admin-user { color: var(--text-muted); font-size: 0.875rem; }
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 1.25rem;
    cursor: pointer;
}
.admin-content { padding: 24px; }

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* Tables */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th, .data-table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { background: #f8f9fa; font-weight: 600; }
.msg-content { max-width: 200px; white-space: normal; word-break: break-word; }
.text-center { text-align: center; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 500; }
.badge-success { background: #d4edda; color: #155724; }
.badge-default { background: #e9ecef; color: #495057; }

.pagination { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.pagination a {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    text-decoration: none;
}
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Login */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.login-card h1 { text-align: center; margin-bottom: 24px; font-size: 1.5rem; }

/* Install */
.install-body { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; }
.install-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.install-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 640px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.install-card h1 { text-align: center; margin-bottom: 8px; }
.install-desc { text-align: center; color: var(--text-muted); margin-bottom: 24px; }
.install-section { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.install-section h2 { font-size: 1rem; margin-bottom: 16px; color: var(--primary); }
.install-actions { text-align: center; }
.install-progress { margin: 24px 0; }
.progress-bar { height: 8px; background: #e9ecef; border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.progress-fill { height: 100%; background: var(--primary); width: 0; transition: width 0.3s; }
.progress-steps { list-style: none; }
.progress-steps li { padding: 8px 0; font-size: 0.875rem; display: flex; align-items: center; gap: 8px; }
.progress-steps li.done::before { content: "✓"; color: var(--success); }
.progress-steps li.running::before { content: "⟳"; color: var(--primary); }
.progress-steps li.error::before { content: "✗"; color: var(--danger); }
.progress-steps li.pending::before { content: "○"; color: var(--text-muted); }
.install-result { text-align: center; margin-top: 24px; }
.result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* Webhook */
.webhook-section { margin-bottom: 24px; }
.webhook-actions { display: flex; gap: 12px; margin: 16px 0; flex-wrap: wrap; }
.webhook-result { padding: 12px; border-radius: var(--radius); margin: 12px 0; font-size: 0.875rem; }
.webhook-result.success { background: #d4edda; color: #155724; }
.webhook-result.error { background: #f8d7da; color: #721c24; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }
.help-box { background: #f8f9fa; padding: 16px; border-radius: var(--radius); margin-top: 16px; font-size: 0.8125rem; }
.help-box h4 { margin-bottom: 8px; }
.help-box code { display: block; background: #e9ecef; padding: 8px; border-radius: 4px; word-break: break-all; margin: 8px 0; font-size: 0.75rem; }
.btn-config-row { margin-bottom: 8px; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.show { display: flex; }
.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }
.original-msg { background: #f8f9fa; padding: 12px; border-radius: var(--radius); font-size: 0.875rem; word-break: break-word; }

/* Responsive - Mobile H5 */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .admin-main { margin-left: 0; }
    .menu-toggle { display: block; }
    .admin-content { padding: 16px; }
    .hero h1 { font-size: 1.5rem; }
    .install-card, .login-card { padding: 24px 16px; }
    .data-table { font-size: 0.8125rem; }
    .data-table th, .data-table td { padding: 8px; }
    .form-row { grid-template-columns: 1fr; }
    .admin-topbar h1 { font-size: 1rem; }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    .stat-value { font-size: 1.5rem; }
    .captcha-row { flex-direction: column; align-items: stretch; }
}

/* iOS safe area */
@supports (padding: env(safe-area-inset-bottom)) {
    .admin-content { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
    .site-footer { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
