/* Single-Page Admin Panel - Black & White Theme */

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

:root {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F7F7F8;
    --bg-tertiary: #ECECF1;
    --text-primary: #353740;
    --text-secondary: #6E6E80;
    --text-light: #8E8EA0;
    --border-color: #E5E5E5;
    --accent-primary: #1A1A1A;
    --accent-hover: #2A2A2A;
    --success-bg: #E6F7F1;
    --success-text: #10A37F;
    --error-bg: #FEE2E2;
    --error-text: #EF4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

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

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

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

.error-message {
    background: var(--error-bg);
    color: var(--error-text);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.flex {
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

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

.form-input, select.form-input {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, select.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.1);
}

.form-input.small {
    max-width: 100px;
}

.form-textarea {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.1);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

.btn-full {
    width: 100%;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
}

.login-footer p {
    font-size: 12px;
    color: var(--text-light);
}

/* Dashboard Layout - Full Width */
.dashboard-page {
    min-height: 100vh;
}

/* Main Content - Full Width */
.main-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Top Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.main-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
}

.status-dot.running {
    background: var(--success-text);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-icon-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    padding: 0;
    margin-right: 8px;
}

.btn-icon-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
}

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

.btn-icon-toggle #toggle-icon {
    display: block;
    line-height: 1;
}

.btn-logout-inline {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s, border-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-logout-inline svg {
    display: block;
}

.btn-logout-inline:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Content Sections */
.content-section {
    margin-bottom: 48px;
}

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

/* Config Cards */
.config-card {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.card-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-group small {
    font-size: 12px;
    color: var(--text-light);
}

/* Sections */
.section-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.section-item:last-child {
    border-bottom: none;
}

.section-row {
    display: grid;
    grid-template-columns: 2fr 3fr 100px 60px 40px;
    gap: 12px;
    align-items: center;
}

/* User Agent Items */
.ua-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.ua-item:last-child {
    border-bottom: none;
}

.ua-item .section-row {
    grid-template-columns: 1fr 40px;
    gap: 12px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border-radius: 24px;
    transition: background-color 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Buttons */
.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.btn-remove {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border-color);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.btn-remove:hover {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: var(--error-text);
}

.btn-danger {
    background: var(--error-text);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.btn-danger:active {
    transform: scale(0.98);
}

/* Floating Save Button */
.btn-save-floating {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: linear-gradient(135deg, #2c3e50 0%, #000000 100%);
    color: white;
    border: none;
    padding: 18px 48px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    z-index: 1000;
    text-transform: uppercase;
}

.btn-save-floating:hover {
    background: linear-gradient(135deg, #000000 0%, #2c3e50 100%);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
}

.btn-save-floating:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

/* Control Panel */
.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.control-status h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

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

/* Logs */
.logs-card {
    margin-top: 0;
}

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

.logs-card .logs-header .card-title {
    margin: 0;
}

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

.btn-small.refresh-icon {
    font-size: 19.5px; /* 150% of 13px */
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.matrix-logs {
    background: #000000;
    color: #ffffff;
    padding: 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.8;
    max-height: 500px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid #333333;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.matrix-logs::-webkit-scrollbar {
    width: 10px;
}

.matrix-logs::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.matrix-logs::-webkit-scrollbar-thumb {
    background: #444444;
    border-radius: 5px;
}

.matrix-logs::-webkit-scrollbar-thumb:hover {
    background: #666666;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transform: translateX(400px);
    transition: transform 0.3s;
    z-index: 2000;
    max-width: 300px;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    border-color: var(--success-text);
    background: var(--success-bg);
    color: var(--success-text);
}

.toast.error {
    border-color: var(--error-text);
    background: var(--error-bg);
    color: var(--error-text);
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 20px 16px;
    }
    
    .top-header {
        flex-direction: column;
        gap: 16px;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .section-row {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-save-floating {
        bottom: 16px;
        right: 16px;
        left: 16px;
        text-align: center;
    }
}

/* Card Header with Icon */
.card-header-with-icon {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header-with-icon .card-title {
    margin: 0;
}

.btn-icon-library {
    background: transparent;
    border: 1px solid var(--border-color);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    color: var(--text-secondary);
}

.btn-icon-library:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.library-domain {
    margin-bottom: 32px;
}

.library-domain:last-child {
    margin-bottom: 0;
}

.library-domain-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.library-sections {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.library-section-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 14px;
    transition: background 0.2s;
}

.library-section-item:hover {
    background: var(--bg-tertiary);
}

.library-section-url {
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
    word-break: break-all;
}

.library-section-id {
    color: var(--text-secondary);
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    background: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 4px;
    margin-left: 12px;
}

/* ========== FEATURE 1: Search Bar Styling ========== */

.library-search-input {
    margin-bottom: 20px;
    width: 100%;
    font-size: 14px;
}

/* ========== FEATURE 3: Click-to-Add Styling ========== */

.library-section-item {
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.library-section-item:hover {
    background: var(--primary-color);
    transform: translateX(4px);
}

.library-add-icon {
    display: none;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    font-weight: bold;
    color: var(--success-color);
}

.library-section-item:hover .library-add-icon {
    display: block;
}

.library-section-item:hover .library-section-id {
    margin-right: 32px;
}

.section-item-highlight {
    animation: highlight-fade 2s ease-out;
}

@keyframes highlight-fade {
    0% { 
        background: rgba(0, 255, 0, 0.2);
        transform: scale(1.02);
    }
    100% { 
        background: transparent;
        transform: scale(1);
    }
}
