/* Call Forwarding Portal Styles */
/* Version: 1.17 */
/* Changelog: 1.17 - Login remember-me checkbox styling */
/* Changelog: 1.15 - Admin per-account recent calls panel */
/* Changelog: 1.14 - Call logs timezone toggle switch; activity expand toggle */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    color: #333;
    line-height: 1.6;
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 40px;
    width: 100%;
    max-width: 450px;
}

.logo-container {
    text-align: center;
    margin-bottom: 20px;
}

.logo {
    max-height: 80px;
    max-width: 100%;
}

.login-box h1 {
    color: #2E8B57;
    text-align: center;
    margin-bottom: 10px;
    font-size: 28px;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #2E8B57;
}

.remember-me-group {
    margin-bottom: 16px;
}

.remember-me-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

.remember-me-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.form-group-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 5px;
}

.form-group-label-row label {
    margin-bottom: 0;
}

.btn-generate-password {
    padding: 0;
    border: none;
    background: none;
    color: #2E8B57;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    white-space: nowrap;
    width: auto;
}

.btn-generate-password:hover {
    color: #218838;
}

.error-message {
    background-color: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid #fcc;
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
    width: 100%;
}

.btn-primary {
    background-color: #2E8B57;
    color: #fff;
}

.btn-primary:hover {
    background-color: #218838;
}

.btn-secondary {
    background-color: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-danger {
    background-color: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background-color: #c82333;
}

/* Dashboard Styles */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-header {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.dashboard-header h1 {
    color: #2E8B57;
    margin: 0;
}

.user-info {
    color: #666;
    font-size: 14px;
}

.logout-link {
    color: #2E8B57;
    text-decoration: none;
    font-weight: bold;
}

.logout-link:hover {
    color: #218838;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.nav-link {
    color: #2E8B57;
    text-decoration: none;
    font-weight: bold;
}

.nav-link:hover {
    color: #218838;
}

.call-logs-card {
    overflow: hidden;
}

.call-logs-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.call-logs-toolbar label {
    color: #666;
    font-size: 14px;
}

.call-logs-tz-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.call-logs-tz-label {
    font-size: 14px;
    color: #666;
    user-select: none;
}

.call-logs-tz-label.is-active {
    color: #2E8B57;
    font-weight: 600;
}

.call-logs-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.call-logs-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.call-logs-switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ced4da;
    border-radius: 26px;
    transition: background 0.2s;
}

.call-logs-switch-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.call-logs-switch input:checked + .call-logs-switch-slider {
    background: #2E8B57;
}

.call-logs-switch input:focus-visible + .call-logs-switch-slider {
    outline: 2px solid #2E8B57;
    outline-offset: 2px;
}

.call-logs-switch input:checked + .call-logs-switch-slider::before {
    transform: translateX(22px);
}

.call-logs-empty {
    color: #666;
    padding: 24px 0;
    text-align: center;
}

.call-logs-table-wrap {
    overflow-x: auto;
}

.call-logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.call-logs-table th,
.call-logs-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.call-logs-table th {
    background: #f8f9fa;
    color: #2E8B57;
    font-weight: 600;
    white-space: nowrap;
}

.call-logs-table tbody tr:hover {
    background: #f8f9fa;
}

.call-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: bold;
    line-height: 1.4;
    white-space: nowrap;
}

.call-status-missed {
    background-color: #fdecea;
    color: #c0392b;
}

.call-status-answered {
    background-color: #eafaf1;
    color: #1e8449;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
}

.status-card {
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.status-card h2 {
    color: #2E8B57;
    margin-bottom: 20px;
    font-size: 24px;
}

.status-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.status-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.status-item label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-weight: bold;
}

.status-item .value {
    font-size: 18px;
    color: #333;
    font-weight: bold;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.status-badge.enabled {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.disabled {
    background-color: #f8d7da;
    color: #721c24;
}

.status-badge:not(.enabled):not(.disabled) {
    background-color: #e2e3e5;
    color: #383d41;
}

.actions-card {
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 0;
    overflow: visible;
}

.actions-card h2 {
    color: #2E8B57;
    margin-bottom: 20px;
    font-size: 24px;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.action-buttons .btn {
    width: 100%;
}

.forward-number-input {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 4px;
    display: none;
    max-width: 100%;
    box-sizing: border-box;
}

.forward-number-input.active {
    display: block;
}

.forward-number-input input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    margin-bottom: 10px;
}

.followme-numbers-container {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.followme-numbers-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 500;
}

.followme-numbers-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-followme {
    padding: 10px 18px;
    background-color: #fff;
    color: #2E8B57;
    border: 2px solid #2E8B57;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    width: auto;
    min-width: 120px;
}

.btn-followme:hover {
    background-color: #2E8B57;
    color: #fff;
}

.btn-followme.selected {
    background-color: #2E8B57;
    color: #fff;
    border-color: #218838;
    box-shadow: 0 2px 4px rgba(46, 139, 87, 0.3);
}

.save-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #ddd;
}

.save-section .btn {
    max-width: 300px;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
    color: #666;
}

.loading.active {
    display: block;
}

/* Loading Spinner */
.spinner {
    display: block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2E8B57;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

/* Small spinner for buttons */
.spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Pulsing Loading Indicator */
.loading-pulse {
    display: inline-block;
    width: 12px;
    height: 12px;
    background-color: #2E8B57;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
    margin: 0 4px;
}

.loading-pulse:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-pulse:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.loading-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
}

.message {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    display: none;
}

.message.active {
    display: block;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Ring-first - compact inline control */
.ring-first-option {
    margin-top: 6px;
    padding: 2px 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    max-width: none;
    box-sizing: border-box;
}

.ring-first-label {
    font-weight: 500;
    font-size: 12px;
    color: #555;
    cursor: pointer;
    user-select: none;
    margin: 0;
    white-space: nowrap;
}

.forward-number-input .ring-seconds-input {
    width: 68px;
    min-width: 68px;
    max-width: 68px;
    padding: 3px 4px;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    border: 1px solid #2E8B57;
    border-radius: 3px;
    background: #fff;
    color: #1a1a1a;
    line-height: 1.1;
    margin: 0;
}

.forward-number-input .ring-seconds-input:focus {
    outline: none;
    border-color: #218838;
    box-shadow: 0 0 0 2px rgba(46, 139, 87, 0.2);
}

/* Admin Page Styles */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.admin-header {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.admin-header h1 {
    color: #2E8B57;
    margin-bottom: 10px;
}

.admin-card {
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.admin-card h2 {
    color: #2E8B57;
    margin-bottom: 20px;
}

.accounts-list {
    margin-top: 20px;
}

.account-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 10px;
}

.account-item .phone {
    font-weight: bold;
    color: #333;
}

.account-item .actions {
    display: flex;
    gap: 10px;
}

.admin-meta {
    font-size: 14px;
    color: #666;
    margin-top: 8px;
}

.admin-hint {
    font-size: 14px;
    color: #666;
    margin: -10px 0 16px;
}

.admin-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: Consolas, 'Courier New', monospace;
    resize: vertical;
}

.admin-textarea:focus {
    outline: none;
    border-color: #2E8B57;
}

.admin-accounts-table-wrap {
    overflow-x: auto;
}

.admin-accounts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-accounts-table th,
.admin-accounts-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
}

.admin-accounts-table th {
    background: #f8f9fa;
    color: #2E8B57;
    font-weight: 600;
}

.admin-phone {
    font-weight: 600;
    white-space: nowrap;
}

.portal-password {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 13px;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
}

.text-muted {
    color: #888;
    font-size: 13px;
}

.admin-actions-cell {
    min-width: 320px;
    white-space: nowrap;
}

.admin-actions-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
}

.admin-reset-password-form,
.admin-delete-form {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.admin-password-input {
    width: 130px;
    min-width: 130px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    flex-shrink: 0;
}

.btn-compact {
    width: auto !important;
    padding: 6px 10px !important;
    font-size: 13px !important;
    flex-shrink: 0;
}

.btn-generate-inline {
    font-size: 12px !important;
    flex-shrink: 0;
}

.admin-activity-row td {
    padding-top: 0;
    border-bottom: 12px solid #e9ecef;
    background: #fafbfc;
}

.admin-activity-panel {
    padding: 8px 12px 12px;
    margin: 0 0 4px;
}

.admin-accounts-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-accounts-header h2 {
    margin-bottom: 0;
}

.admin-activity-days-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.admin-activity-days-form label {
    font-size: 13px;
    color: #666;
    margin: 0;
}

.admin-activity-days-select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}

.admin-activity-heading {
    font-size: 12px;
    font-weight: 600;
    color: #2E8B57;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.btn-toggle-activity {
    margin: 4px 0 8px;
    padding: 0;
    border: none;
    background: none;
    color: #2E8B57;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.btn-toggle-activity:hover {
    color: #218838;
}

.admin-activity-more[hidden] {
    display: none;
}

.admin-activity-empty {
    font-size: 13px;
    color: #888;
    margin: 0;
}

.admin-activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.admin-activity-list li {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 10px;
    font-size: 13px;
    padding: 5px 0;
    border-bottom: 1px solid #eef0f2;
}

.admin-activity-list li:last-child {
    border-bottom: none;
}

.admin-activity-time {
    flex-shrink: 0;
    color: #666;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    min-width: 140px;
}

.admin-activity-label {
    flex: 1;
    min-width: 0;
    color: #333;
}

.admin-activity-ip {
    flex-shrink: 0;
    color: #999;
    font-size: 11px;
}

.admin-calls-row td {
    background: #fafcff;
    border-top: none;
    padding-top: 0;
}

.admin-calls-panel {
    padding: 12px 0 4px;
    border-top: 1px dashed #d0d8e0;
}

.admin-calls-heading {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 10px;
}

.admin-calls-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 12px;
    font-size: 13px;
}

.admin-calls-toolbar label {
    color: #666;
}

.admin-calls-period {
    font-size: 12px;
}

.admin-calls-loading {
    display: none;
    padding: 16px 0;
}

.admin-calls-loading.active {
    display: block;
}

.admin-calls-table-wrap {
    max-height: 360px;
    overflow: auto;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .login-box {
        padding: 30px 20px;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .status-info {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    .account-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .account-item .actions {
        width: 100%;
        margin-top: 10px;
    }
    
    .account-item .actions .btn {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .login-box h1 {
        font-size: 24px;
    }
    
    .status-card h2,
    .actions-card h2 {
        font-size: 20px;
    }
}
