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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

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

/* Navbar */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 0.4rem 0;
    margin-bottom: 0.75rem;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar .logo {
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.nav-links a {
    color: white;
    text-decoration: none;
    transition: opacity 0.2s;
}

.nav-links a:hover {
    opacity: 0.8;
}

.language-switcher {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.language-switcher .lang-link {
    color: white;
    text-decoration: none;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

.language-switcher .lang-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.language-switcher .lang-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 0.5rem;
}

.flash {
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

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

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: #2980b9;
}

.btn-primary {
    background-color: #3498db;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

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

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.card-header h3 {
    margin: 0;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.table thead {
    background-color: #f8f9fa;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.table th {
    font-weight: 600;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-live {
    background-color: #3498db;
    color: white;
}

.badge-notify {
    background-color: #9b59b6;
    color: white;
}

.badge-created {
    background-color: #95a5a6;
    color: white;
}

.badge-running {
    background-color: #f39c12;
    color: white;
}

.badge-completed {
    background-color: #27ae60;
    color: white;
}

.badge-pending {
    background-color: #95a5a6;
    color: white;
}

.badge-dialing {
    background-color: #27ae60;
    color: white;
}

.badge-dialed {
    background-color: #3498db;
    color: white;
}

.badge-answered {
    background-color: #27ae60;
    color: white;
}

.badge-failed {
    background-color: #e74c3c;
    color: white;
}

.badge-machine {
    background-color: #f39c12;
    color: white;
}

/* Forms */
.form {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #666;
    font-size: 0.85rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.campaign-meta {
    display: flex;
    gap: 0.5rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.stat-card {
    background: white;
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-align: center;
}

.stat-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c3e50;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid #dee2e6;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #2c3e50;
}

.tab-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Campaign Control Card - Two Column Layout */
.campaign-control-card {
    margin-bottom: 0.75rem;
}

.control-card-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.control-column-left,
.control-column-right {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-item h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
}

.control-description-small {
    color: #666;
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.4;
}

.deeplink-hint {
    display: block;
    color: #999;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    font-style: italic;
    line-height: 1.4;
}

/* TTS Template Display */
.tts-template-display {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tts-text-preview {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.call-route-preview {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0;
    background-color: transparent;
    border: 0;
    border-radius: 0;
}

.call-route-preview .form-group {
    width: 100%;
    margin-bottom: 0;
}

.call-route-select {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

.tts-text {
    flex: 1;
    color: #333;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.tts-text:empty::before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
}

/* Campaign Controls */
.campaign-controls-container {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.campaign-control-btn {
    min-width: 100px;
    text-align: center;
}

.control-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Responsive: Stack columns on mobile */
@media (max-width: 768px) {
    .control-card-columns {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Config Editor */
.config-editor {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.config-files {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.config-file {
    display: flex;
    flex-direction: column;
}

.config-file h3 {
    margin-bottom: 0.5rem;
}

.config-textarea {
    width: 100%;
    min-height: 400px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    resize: vertical;
}

.config-actions {
    text-align: center;
}

/* Scrollable tables for long target lists */
.scroll-table {
    max-height: 400px;
    overflow-y: auto;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.empty-state p {
    margin-bottom: 0.5rem;
}

/* Error Page */
.error-page {
    text-align: center;
    padding: 4rem 2rem;
}

.error-page h1 {
    font-size: 4rem;
    color: #e74c3c;
    margin-bottom: 1rem;
}

/* Modal */
.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.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover,
.modal-close:focus {
    color: #000;
}

.modal .form-group {
    padding: 0 1.5rem;
}

.modal .form-actions {
    padding: 1.5rem;
    border-top: 1px solid #eee;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-warning:hover {
    background-color: #e67e22;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar .container {
        flex-wrap: wrap;
    }

    .nav-links {
        order: 3;
        width: 100%;
        margin-top: 1rem;
        justify-content: center;
    }

    .language-switcher {
        order: 2;
    }

    .config-files {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-content {
    background: white;
    padding: 2rem 3rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-text {
    color: #333;
    font-size: 1rem;
    margin: 0;
}

/* Prevent scrolling when loading */
body.loading-active {
    overflow: hidden;
}

/* Disabled button state */
.btn-disabled,
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Call list message styles */
.call-list-message {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

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

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

/* Landing page */
.landing {
    max-width: 640px;
    margin: 4rem auto;
    text-align: center;
}

.landing-title {
    margin-bottom: 1rem;
}

.landing-lead {
    color: #555;
    margin-bottom: 2rem;
}

.landing-note {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.btn-landing {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* Sign out sits inline with the language switcher */
.logout-form {
    display: inline;
    margin: 0;
}
