:root {
    --primary: #1da1f2;
    --primary-dark: #1a91da;
    --success: #22bb33;
    --success-dark: #1ea52c;
    --danger: #ff4d4f;
    --danger-dark: #e04345;
    --secondary: #e1e8ed;
    --secondary-dark: #d1d9e0;
    --dark: #14171a;
    --gray: #657786;
    --light-gray: #aab8c2;
    --extra-light-gray: #e1e8ed;
    --background: #f5f8fa;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--background);
    color: #333;
    line-height: 1.6;
}

/* Login Form Styles */
#loginContainer {
    max-width: 400px;
    margin: 50px auto;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

.login-header h2 {
    color: #333;
    margin-bottom: 5px;
}

.login-header p {
    color: #666;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(29, 161, 242, 0.2);
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.3s;
}

.btn-login:hover {
    opacity: 0.9;
}

.license-info {
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid var(--primary);
}

.license-info h4 {
    margin: 0 0 10px 0;
    color: #333;
}

.license-info p {
    margin: 5px 0;
    color: #666;
}

/* Main Container */
#mainContainer {
    display: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: relative;
}

h1 {
    margin: 0;
    font-size: 28px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.subtitle {
    margin: 5px 0 0;
    opacity: 0.9;
    font-weight: 400;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

/* Card Bot Styles */
.card-bot {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 20px;
    border: 1px solid #e1e8ed;
}

.card-bot:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.bot-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 15px;
}

.bot-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.bot-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--extra-light-gray);
}

.bot-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--dark);
}

.bot-meta {
    font-size: 0.875rem;
    color: var(--gray);
    margin-top: 5px;
}

.bot-meta .dot {
    margin: 0 5px;
}

.status-online, .status-offline {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-online {
    background-color: #e1f7e3;
    color: var(--success);
}

.status-offline {
    background-color: #f8d7da;
    color: var(--danger);
}

.bot-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.chip {
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

.chip.mode {
    background-color: #e8f4fd;
    color: var(--primary);
}

.chip.record {
    background-color: #f0f2f5;
    color: #65676b;
}

.chip.process-default {
    background-color: #f7f7f7;
    color: var(--gray);
}

.chip.process-recording {
    background-color: #fff3cd;
    color: #856404;
}

.chip.process-live {
    background-color: #e8f4fd;
    color: var(--primary);
}

.chip.process-ready {
    background-color: #d4edda;
    color: #155724;
}

.countdown-container {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin-bottom: 15px;
}

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

.countdown-label {
    font-weight: 600;
    color: #495057;
}

.countdown-time {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: bold;
    color: #dc3545;
    background: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #dc3545;
}

.countdown-track {
    width: 100%;
    height: 10px;
    background-color: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
}

.countdown-progress {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 5px;
    transition: width 0.5s ease;
}

.divider {
    height: 1px;
    background-color: var(--extra-light-gray);
    margin: 15px 0;
}

.bot-details {
    margin-bottom: 15px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 6px;
}

.detail-label {
    font-size: 12px;
    color: var(--gray);
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
}

.note {
    font-size: 14px;
    color: var(--gray);
    font-style: italic;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 6px;
    margin: 10px 0;
}

.notification {
    background-color: #e8f4fd;
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    border-left: 4px solid var(--primary);
}

.notification-text {
    color: var(--primary);
    font-size: 14px;
    margin: 0;
}

.hint {
    font-size: 12px;
    color: var(--gray);
    margin-top: 5px;
    padding-left: 10px;
    border-left: 2px solid var(--primary);
}

.bot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

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

.btn-stop {
    background-color: #ffc107;
    color: #212529;
}

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

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

.btn-edit {
    background-color: transparent;
    border: 1px solid #dee2e6;
    color: #6c757d;
}

.btn-delete {
    background-color: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-record:hover {
    background-color: var(--primary-dark);
}

.btn-stop:hover {
    background-color: #e0a800;
}

.btn-live:hover {
    background-color: var(--success-dark);
}

.btn-stop-live:hover {
    background-color: var(--danger-dark);
}

.btn-edit:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #495057;
}

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

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

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

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

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

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

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

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

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

.btn-warning {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
    border-color: #d39e00;
    color: #212529;
}

.btn-ghost {
    background-color: transparent;
    border: 1px solid #dee2e6;
    color: #6c757d;
}

.btn-ghost:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #495057;
}

.btn-outline-accent {
    background-color: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

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

.btn-outline-danger {
    background-color: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

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

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: none;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.loading {
    text-align: center;
    padding: 20px;
    display: none;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: modalopen 0.3s;
}

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

.modal-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #eee;
}

.modal-body {
    padding: 20px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .countdown-header {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
    
    .countdown-time {
        font-size: 1rem;
    }
    
    .bot-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .bot-actions {
        flex-direction: column;
    }
    
    .bot-actions .btn {
        width: 100%;
    }
}

/* Utility Classes */
.d-flex {
    display: flex !important;
}

.align-items-start {
    align-items: flex-start !important;
}

.align-items-center {
    align-items: center !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.gap-3 {
    gap: 1rem !important;
}

.m-0 {
    margin: 0 !important;
}

.mt-1 {
    margin-top: 0.25rem !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.my-3 {
    margin-top: 1rem !important;
    margin-bottom: 1rem !important;
}

.h5 {
    font-size: 1.25rem;
    font-weight: 600;
}

.small {
    font-size: 0.875rem;
}

.small-muted {
    color: #6c757d !important;
}

.text-accent {
    color: var(--primary) !important;
}

.avatar-xl {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--extra-light-gray);
}

.pill-status {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.pill-online {
    background-color: #e1f7e3;
    color: var(--success);
}

.pill-offline {
    background-color: #f8d7da;
    color: var(--danger);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.chip {
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

.chip-accent {
    background-color: #e8f4fd;
    color: var(--primary);
}

.chip-neutral {
    background-color: #f0f2f5;
    color: #65676b;
}

.chip-soft {
    background-color: #f7f7f7;
    color: var(--gray);
}

.chip-warning {
    background-color: #fff3cd;
    color: #856404;
}

.chip-success {
    background-color: #d4edda;
    color: #155724;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.5rem;
    margin-left: -0.5rem;
}

.col-6, .col-12 {
    position: relative;
    width: 100%;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

.col-6 {
    flex: 0 0 50%;
    max-width: 50%;
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
}

.g-2 {
    margin-right: -0.5rem;
    margin-left: -0.5rem;
}

.g-2 > [class^="col-"] {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

.kpi {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
}

.kpi-label {
    font-size: 12px;
    color: var(--gray);
    margin-bottom: 5px;
}

.kpi-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
}

.actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

/* สไตล์สำหรับปุ่มเพิ่มบอท */
#addBotBtn {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* สไตล์สำหรับ modal เพิ่มบอท */
#addBotPane {
    transition: opacity 0.3s ease;
}

/* สไตล์สำหรับ range input */
.form-range {
    width: 100%;
    height: 8px;
}

/* สไตล์สำหรับปุ่มโหมด */
#modePills .btn {
    margin-bottom: 5px;
}

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

/* สไตล์สำหรับข้อความนับจำนวนอักขระ */
#noteCount {
    color: var(--primary);
    font-weight: 500;
}

/* สไตล์สำหรับฟอร์มเพิ่มบอท */
#stepCookie .form-group {
    margin-bottom: 15px;
}

#usernameInput {
    margin-top: 8px;
}


/* Header Actions Styles */
.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ปุ่มเพิ่มบอท */
.btn-add-bot {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(106, 17, 203, 0.3);
}

.btn-add-bot:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 17, 203, 0.4);
}

.btn-add-bot:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(106, 17, 203, 0.3);
}

/* ปุ่มออกจากระบบ */
.btn-logout {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-logout:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Responsive Design for Header */
@media (max-width: 768px) {
    header {
        padding: 15px;
    }
    
    .header-actions {
        flex-direction: column;
        width: 100%;
        gap: 10px;
        margin-top: 15px;
    }
    
    .btn-add-bot,
    .btn-logout {
        width: 100%;
        justify-content: center;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .header-actions {
        flex-direction: column;
    }
    
    .btn-add-bot,
    .btn-logout {
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* Icon Styles */
.btn-icon {
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Header Content Layout */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 15px;
}

.header-title {
    flex: 1;
    min-width: 200px;
}

/* Animation for buttons */
@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(106, 17, 203, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 16px rgba(106, 17, 203, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(106, 17, 203, 0.3);
    }
}

.btn-add-bot:focus {
    animation: pulse 0.6s ease;
    outline: none;
}

/* Glassmorphism effect for logout button */
.btn-logout {
    position: relative;
    overflow: hidden;
}

.btn-logout::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.btn-logout:hover::before {
    left: 100%;
}

/* สไตล์สำหรับปุ่มที่ disabled */
.btn-add-bot:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background: linear-gradient(135deg, #cccccc 0%, #999999 100%);
}

.btn-add-bot:disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(106, 17, 203, 0.3);
}