/* ============================================
   WhatsApp Admin Panel - Светлая тема
   ============================================ */

:root {
    --primary-color: #25D366;
    --primary-hover: #20bd5a;
    --secondary-color: #34B7F1;
    --danger-color: #dc3545;
    --danger-hover: #c82333;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --info-color: #17a2b8;

    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --bg-card: #ffffff;

    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-muted: #95a5a6;

    --border-color: #e0e0e0;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    --border-radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: var(--bg-white);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    margin-bottom: 20px;
    animation: fadeInDown 0.6s ease;
}

.login-header h1 {
    color: var(--text-primary);
    font-size: 28px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    animation: fadeInUp 0.6s ease;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: var(--transition);
    background: var(--bg-white);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

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

.btn-success:hover:not(:disabled) {
    background: #218838;
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */

.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    box-shadow: var(--shadow-sm);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

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

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
}

.nav-item .icon {
    margin-right: 12px;
    font-size: 20px;
}

.nav-item:hover:not(.disabled) {
    background: var(--bg-light);
    color: var(--primary-color);
}

.nav-item.active {
    background: rgba(37, 211, 102, 0.1);
    color: var(--primary-color);
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

.nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.badge {
    margin-left: auto;
    background: var(--warning-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px;
    background: var(--bg-light);
    border-radius: 8px;
}

.user-avatar {
    font-size: 24px;
    margin-right: 10px;
}

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

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
    background: var(--bg-light);
    min-height: 100vh;
}

.content-header {
    margin-bottom: 30px;
}

.content-header h1 {
    font-size: 32px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 16px;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* Status Container */
.status-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    position: relative;
    animation: pulse 2s infinite;
}

.status-dot.status-connected {
    background: var(--success-color);
}

.status-dot.status-disconnected {
    background: var(--danger-color);
    animation: none;
}

.status-dot.status-pending {
    background: var(--warning-color);
}

.status-info {
    display: flex;
    flex-direction: column;
}

.status-label {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.status-description {
    font-size: 14px;
    color: var(--text-secondary);
}

.status-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* QR Code */
.qr-container {
    margin-top: 24px;
    padding: 24px;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    text-align: center;
}

.qr-container h4 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.qr-container p {
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.qr-code {
    display: inline-block;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

.qr-code img {
    max-width: 300px;
    height: auto;
    display: block;
}

.loading, .error {
    padding: 40px;
    color: var(--text-secondary);
}

.error {
    color: var(--danger-color);
}

/* Info Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.info-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.info-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.info-card-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border-radius: 10px;
}

.info-card-content h4 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.info-card-content p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Feature List */
.feature-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.feature-list li {
    padding: 12px 16px;
    background: var(--bg-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

/* ============================================
   FLASH MESSAGES
   ============================================ */

.flash-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.flash {
    background: white;
    padding: 16px 20px;
    margin-bottom: 12px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid;
}

.flash-success {
    border-left-color: var(--success-color);
}

.flash-error {
    border-left-color: var(--danger-color);
}

.flash-warning {
    border-left-color: var(--warning-color);
}

.flash-info {
    border-left-color: var(--info-color);
}

.flash-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    margin-left: 16px;
    line-height: 1;
}

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

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 0 8px currentColor;
        opacity: 0.5;
    }
}

textarea#assistantPrompt {
    width: 100%;
}

/* Предотвращение зума в input на iOS */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
textarea,
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Улучшенные стили для textarea */
textarea {
    resize: vertical;
    min-height: 100px;
}

/* ============================================
   ASSISTANT PAGE STYLES
   ============================================ */

.assistant-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-light);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
}

.control-buttons {
    display: flex;
    gap: 12px;
}

.prompt-templates {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.prompt-templates small {
    color: var(--text-secondary);
    margin-right: 8px;
}

.test-chat {
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-light);
}

.chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.chat-message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
}

.chat-message-user {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-assistant {
    align-self: flex-start;
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.chat-input-container {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: white;
    border-top: 2px solid var(--border-color);
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.conversation-item {
    padding: 16px;
    background: var(--bg-light);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.conversation-number {
    font-weight: 600;
    color: var(--text-primary);
}

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

.conversation-preview {
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

.card-info {
    background: #fff8e1;
    border-left: 4px solid var(--warning-color);
}

.card-info h4 {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.card-info ul {
    margin-left: 20px;
    line-height: 1.8;
}

.card-info li {
    color: var(--text-primary);
    font-size: 14px;
}

/* ============================================
   MOBILE MENU TOGGLE
   ============================================ */

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1002;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    /* Плавная анимация перемещения */
    transition: left 0.3s ease, background 0.3s ease;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Кнопка перемещается вправо когда меню открыто */
.mobile-menu-toggle.menu-open {
    left: 200px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 80px 15px 20px;
    }

    .status-container {
        flex-direction: column;
        align-items: flex-start;
    }

    .status-actions {
        width: 100%;
        flex-direction: column;
    }

    .status-actions .btn {
        width: 100%;
    }

    .content-header {
        margin-bottom: 20px;
    }

    .content-header h1 {
        font-size: 24px;
    }

    .subtitle {
        font-size: 14px;
    }

    .card-body {
        padding: 16px;
    }

    .card-header {
        padding: 16px;
    }

    /* Формы */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Предотвращает зум на iOS */
    }

    /* Кнопки */
    .btn {
        padding: 14px 20px;
        font-size: 16px;
    }

    .btn-sm {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Flash сообщения */
    .flash-container {
        left: 10px;
        right: 10px;
        top: 80px;
        max-width: none;
    }

    .flash {
        font-size: 14px;
        padding: 12px 16px;
    }

    /* QR код */
    .qr-code img {
        max-width: 250px;
    }

    /* Информационные карточки */
    .info-card,
    .quick-link-card {
        padding: 16px;
    }

    .info-card-icon,
    .quick-link-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    /* Сетки */
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .feature-list {
        grid-template-columns: 1fr;
    }

    /* Формы на мобильных */
    .form-row {
        grid-template-columns: 1fr !important;
    }

    .form-control {
        width: 100% !important;
        min-width: auto !important;
        font-size: 16px !important;
    }

    input.form-control,
    textarea.form-control,
    select.form-control {
        font-size: 16px !important;
    }

    /* Все input поля на мобильных */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* Таблицы и списки */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Статус индикатор */
    .status-indicator {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* Progress bar */
    .progress-stats {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    /* Log container */
    .log-container {
        font-size: 12px;
        max-height: 200px;
    }

    /* Модальные окна */
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        padding: 20px !important;
        margin: 10px;
    }

    /* Preview section */
    .preview-section {
        margin: 16px 0;
    }

    .preview-result {
        padding: 12px;
    }

    .preview-message {
        padding: 12px;
        font-size: 14px;
    }

    /* Action buttons */
    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .action-buttons .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 30px 20px;
    }

    .main-content {
        padding: 80px 10px 15px;
    }

    .content-header h1 {
        font-size: 20px;
    }

    .subtitle {
        font-size: 13px;
    }

    /* Кнопки в строке */
    .status-actions,
    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }

    .status-actions .btn,
    .modal-actions .btn {
        width: 100%;
    }

    /* Карточки */
    .card {
        margin-bottom: 15px;
    }

    .card-body {
        padding: 12px;
    }

    .card-header h3 {
        font-size: 16px;
    }

    /* QR код */
    .qr-container {
        padding: 16px;
    }

    .qr-code {
        padding: 15px;
    }

    .qr-code img {
        max-width: 200px;
    }

    /* Промпты и текстовые поля */
    .prompt-examples,
    .prompt-templates {
        flex-direction: column;
        align-items: stretch;
    }

    .prompt-btn {
        width: 100%;
        text-align: center;
    }

    /* Assistant control */
    .assistant-control {
        flex-direction: column;
        align-items: stretch;
    }

    .control-buttons {
        width: 100%;
        flex-direction: column;
    }

    .control-buttons .btn {
        width: 100%;
    }

    .status-badge {
        width: 100%;
        justify-content: center;
    }

    /* Test chat */
    .chat-messages {
        height: 300px;
    }

    .chat-message {
        max-width: 85%;
    }

    .chat-input-container {
        flex-direction: column;
    }

    .chat-input-container .btn {
        width: 100%;
    }

    /* Conversations */
    .conversation-item {
        padding: 12px;
    }

    .conversation-header {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }

    /* Счетчики */
    .char-counter,
    .phone-counter {
        font-size: 12px;
    }

    /* Settings группы */
    .settings-group {
        gap: 15px;
    }

    .setting-item label {
        font-size: 13px;
    }

    .setting-item small {
        font-size: 12px;
    }
}

@media (max-width: 360px) {
    .main-content {
        padding: 75px 8px 12px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 14px;
    }

    .content-header h1 {
        font-size: 18px;
    }
}

