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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

.login-box {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #25D366;
    font-size: 2rem;
    font-weight: 700;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid #f1aeb5;
    text-align: center;
}

/* Navigation */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-content h1 {
    color: #25D366;
    font-size: 1.8rem;
    font-weight: 700;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Overview Stats */
.overview-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-card h3 {
    color: #666;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #25D366;
}

/* Numbers Grid */
.numbers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
}

.number-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.number-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.number-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #25D366, #128C7E);
}

.number-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.number-header h3 {
    font-size: 1.3rem;
    color: #333;
    font-weight: 600;
}

.number-info {
    margin-bottom: 1.5rem;
}

.phone-number, .phone-display {
    color: #25D366;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.created-date {
    color: #666;
    font-size: 0.9rem;
}

.number-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Add Number Card */
.add-card {
    border: 2px dashed #25D366;
    background: rgba(37, 211, 102, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-card:hover {
    background: rgba(37, 211, 102, 0.1);
    border-color: #20b358;
}

.add-content {
    text-align: center;
}

.add-icon {
    font-size: 3rem;
    color: #25D366;
    margin-bottom: 1rem;
}

.add-content h3 {
    color: #25D366;
    margin-bottom: 0.5rem;
}

.add-content p {
    color: #666;
}

/* Status Badges */
.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-connected {
    background: #d4edda;
    color: #155724;
}

.status-connecting, .status-qr_received, .status-authenticated {
    background: #fff3cd;
    color: #856404;
}

.status-disconnected, .status-auth_failed, .status-error {
    background: #f8d7da;
    color: #721c24;
}

/* QR Code Section */
.qr-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: rgba(37, 211, 102, 0.05);
    border-radius: 10px;
    text-align: center;
}

.qr-label {
    color: #25D366;
    font-weight: 600;
    margin-bottom: 1rem;
}

#qrcode,
.qr-code {
    margin: 0 auto;
    display: block;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
}

.qr-instructions {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.qr-instructions p {
    margin-bottom: 0.3rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: #25D366;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #20b358;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

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

.btn-danger:hover {
    background: #c82333;
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Section Cards */
.section-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

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

.section-header h2 {
    color: #333;
    font-size: 1.4rem;
    font-weight: 600;
}

.section-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Connection Panel */
.connection-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: rgba(37, 211, 102, 0.05);
    border-radius: 10px;
}

.status-info {
    flex: 1;
}

.status-indicator {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

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

/* API Keys */
.api-endpoint-info {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
}

.api-endpoint-info h3 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.endpoint-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

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

.endpoint-item code {
    background: #25D366;
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 5px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9rem;
}

.endpoint-desc {
    color: #666;
    font-size: 0.9rem;
}

.api-keys-list {
    space-y: 1rem;
}

.api-key-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: rgba(37, 211, 102, 0.05);
    border-radius: 10px;
    margin-bottom: 1rem;
}

.key-info {
    flex: 1;
}

.key-info h4 {
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.api-key-display {
    background: #333;
    color: #25D366;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    display: inline-block;
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.key-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.key-meta span {
    font-size: 0.8rem;
    color: #666;
}

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

/* Webhooks */
.webhook-list {
    space-y: 1rem;
}

.webhook-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem;
    background: rgba(37, 211, 102, 0.05);
    border-radius: 10px;
    margin-bottom: 1rem;
}

.webhook-info {
    flex: 1;
}

.webhook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.webhook-header h4 {
    color: #333;
    font-size: 1.1rem;
}

.webhook-details {
    space-y: 0.5rem;
}

.webhook-url {
    color: #25D366;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9rem;
    word-break: break-all;
    margin-bottom: 0.5rem;
}

.monitor-types {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.monitor-type {
    padding: 0.3rem 0.6rem;
    border-radius: 15px;
    font-size: 0.8rem;
    background: #f0f0f0;
    color: #666;
}

.monitor-type.active {
    background: #25D366;
    color: white;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    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: #ccc;
    transition: .4s;
    border-radius: 24px;
}

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

input:checked + .toggle-slider {
    background-color: #25D366;
}

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

/* Messages */
.messages-list {
    max-height: 400px;
    overflow-y: auto;
}

.message-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.message-item:hover {
    background: rgba(37, 211, 102, 0.02);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.message-from {
    font-weight: 600;
    color: #25D366;
}

.message-time {
    font-size: 0.8rem;
    color: #666;
}

.webhook-status {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
}

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

.webhook-status.status-failed {
    background: #f8d7da;
    color: #721c24;
}

.message-body {
    color: #333;
    margin-bottom: 0.5rem;
}

.message-media {
    color: #25D366;
    font-size: 0.9rem;
    font-style: italic;
}

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header h2 {
    color: #333;
    font-size: 1.3rem;
}

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

.close:hover {
    color: #333;
}

.modal form {
    padding: 2rem;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #f0f0f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
}

/* Utility */
.no-data {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

.warning-text {
    color: #856404;
    background: #fff3cd;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

/* Result messages */
.result {
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
}

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

.result.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f1aeb5;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .nav-content {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }

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

    .overview-stats {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .connection-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .api-key-item,
    .webhook-item {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

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

    .modal form {
        padding: 1.5rem;
    }

    .endpoint-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Modern UI Enhancements */
:root {
    --primary-color: #25D366;
    --secondary-color: #667eea;
    --accent-color: #764ba2;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --shadow-light: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 20px rgba(0,0,0,0.15);
    --shadow-heavy: 0 8px 40px rgba(0,0,0,0.2);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced buttons with modern animations */
.btn {
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    transform: translateY(0);
    box-shadow: var(--shadow-light);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-light);
}

/* Enhanced cards with better shadows and animations */
.section-card,
.number-card,
.webhook-item,
.api-key-item {
    transition: var(--transition);
    border: 1px solid rgba(255,255,255,0.1);
}

.section-card:hover,
.number-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-heavy);
}

/* Smooth status indicators */
.status-badge,
.status-indicator {
    transition: var(--transition);
    animation: pulse 2s infinite;
}

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

.status-connected {
    background: var(--success-color);
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.3);
}

.status-disconnected {
    background: var(--danger-color);
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.3);
}

.status-connecting {
    background: var(--warning-color);
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.3);
}

/* Enhanced modals */
.modal {
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
}

.modal-content {
    animation: slideIn 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: var(--shadow-heavy);
}

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

/* Enhanced form inputs */
.form-group input,
.form-group select,
.form-group textarea {
    transition: var(--transition);
    border: 2px solid #e9ecef;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
    transform: scale(1.02);
}

/* Enhanced navbar */
.navbar {
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    box-shadow: var(--shadow-light);
}

/* Loading animations */
.refresh-icon {
    transition: transform 0.3s ease;
}

.btn:hover .refresh-icon {
    transform: rotate(180deg);
}

/* Enhanced webhook status */
.webhook-status.status-success {
    background: var(--success-color);
    color: white;
    animation: successPulse 1s ease;
}

.webhook-status.status-failed {
    background: var(--danger-color);
    color: white;
    animation: errorShake 0.5s ease;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Enhanced toggle switches */
.toggle-switch {
    position: relative;
    display: inline-block;
}

.toggle-slider {
    transition: var(--transition);
    box-shadow: inset 0 0 0 2px #e9ecef;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-color);
    box-shadow: 0 0 10px rgba(37, 211, 102, 0.3);
}

/* Enhanced progress indicators */
.progress-ring {
    width: 60px;
    height: 60px;
}

.progress-ring circle {
    transition: stroke-dasharray 0.3s ease;
    stroke: var(--primary-color);
    stroke-width: 3;
    fill: transparent;
    stroke-dasharray: 0 100;
}

/* Smooth scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.5);
}

/* Enhanced mobile responsiveness */
@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }

    .section-card {
        margin: 0.5rem 0;
        padding: 1rem;
    }

    .navbar h1 {
        font-size: 1.2rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

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

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --card-bg: #2d2d2d;
        --text-color: #ffffff;
        --border-color: #444;
    }
}

/* Accessibility improvements */
.btn:focus,
input:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    .section-card {
        border: 2px solid #333;
    }
}