/**
 * WebPhone Wrapper Styles
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    height: 100vh;
}

.wrapper-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* Sidebar WebPhone */
.webphone-sidebar {
    width: 0;
    height: 100vh;
    background: #2c3e50;
    color: white;
    position: relative;
    transition: width 0.3s ease, margin-left 0.3s ease;
    z-index: 1000;
    flex-shrink: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.webphone-sidebar.expanded {
    width: 350px;
    box-shadow: 3px 0 15px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 80px;
    background: #2c3e50;
    border: none;
    border-radius: 0 8px 8px 0;
    color: white;
    cursor: pointer;
    display: none; /* Nascosto di default, mostrato dopo login via JS */
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: left 0.3s ease, background 0.2s;
}

.webphone-sidebar.expanded .sidebar-toggle {
    left: 350px;
}

.sidebar-toggle:hover {
    background: #34495e;
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
    transform: rotate(180deg);
}

.webphone-sidebar.expanded .sidebar-toggle svg {
    transform: rotate(0deg);
}

/* WebPhone Content */
.webphone-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.phone-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

.header-title h3 {
    margin: 0;
}

.header-timer {
    font-size: 14px;
    font-weight: bold;
    color: #95a5a6;
    display: block !important;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.header-timer.visible {
    color: #2ecc71;
    opacity: 1;
    font-size: 16px;
}

.phone-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e74c3c;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: #27ae60;
}

.status-dot.calling {
    background: #f39c12;
    animation: pulse-fast 0.8s infinite;
}

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

@keyframes pulse-fast {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.2); }
}

.phone-display {
    background: #34495e;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.display-number {
    margin-top: 10px;
}

.display-number input {
    width: 100%;
    padding: 12px;
    font-size: 18px;
    border: none;
    border-radius: 4px;
    background: #2c3e50;
    color: white;
    text-align: center;
}

.display-timer {
    text-align: center;
    font-size: 24px;
    margin-top: 10px;
    display: none;
}

.display-timer.visible {
    display: block;
}

.phone-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.key {
    padding: 15px;
    background: #34495e;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}

.key:hover {
    background: #3d566e;
}

.key:active {
    background: #2c3e50;
}

.phone-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-call:hover:not(:disabled) {
    background: #229954;
}

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

.btn-hangup:hover:not(:disabled) {
    background: #c0392b;
}

.btn-mute, .btn-hold {
    background: #3498db;
    color: white;
}

.btn-mute:hover:not(:disabled), .btn-hold:hover:not(:disabled) {
    background: #2980b9;
}

/* Phone Disconnect Section */
.phone-disconnect {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-disconnect {
    background: #95a5a6;
    color: white;
    width: 100%;
}

.btn-disconnect:hover:not(:disabled) {
    background: #7f8c8d;
}

.btn-disconnect:disabled {
    opacity: 0.3;
}

/* Main Content Area */
.main-content {
    flex: 1;
    height: 100vh;
    position: relative;
    overflow: auto;
    background: #ecf0f1;
}

.main-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Configuration Container */
.config-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .config-container {
        grid-template-columns: 1fr;
    }
}

/* Configuration Card */
.config-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.config-card h2 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 24px;
}

.config-description {
    color: #7f8c8d;
    margin-bottom: 30px;
}

/* Form Styles */
.config-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.form-group label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    padding: 12px;
    border: 2px solid #dfe6e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.form-group small {
    color: #95a5a6;
    font-size: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Advanced Options */
.form-advanced {
    margin-top: 10px;
}

.btn-toggle-advanced {
    background: #ecf0f1;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-weight: 600;
    color: #2c3e50;
    transition: background 0.3s;
}

.btn-toggle-advanced:hover {
    background: #dfe6e9;
}

.btn-toggle-advanced svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
}

.advanced-options {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ecf0f1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn-primary {
    background: #27ae60;
    color: white;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
    flex: 1;
}

.btn-primary:hover {
    background: #229954;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

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

/* Connection Status */
.connection-status {
    margin-top: 20px;
    padding: 15px;
    background: #ecf0f1;
    border-radius: 8px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.connection-status .status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #95a5a6;
}

.connection-status .status-dot.status-connecting {
    background: #f39c12;
    animation: pulse 1.5s infinite;
}

.connection-status .status-dot.status-connected {
    background: #27ae60;
}

.connection-status .status-dot.status-error {
    background: #e74c3c;
}

.status-text {
    font-weight: 600;
    color: #2c3e50;
}

/* Info Card */
.info-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

.info-card h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 20px;
}

.info-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #ecf0f1;
}

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

.info-item strong {
    color: #2c3e50;
    font-size: 14px;
}

.info-item span {
    color: #7f8c8d;
    font-size: 14px;
}

/* Logs */
.info-logs {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #ecf0f1;
}

.info-logs h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 16px;
}

.log-container {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.log-error {
    color: #e74c3c;
}

.log-entry.log-warning {
    color: #f39c12;
}

.log-entry.log-success {
    color: #27ae60;
}

/* Success Message */
.success-message {
    background: #27ae60;
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    animation: slideIn 0.3s ease;
}

.success-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.success-content svg {
    width: 24px;
    height: 24px;
}

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

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

/* Audio elements */
audio {
    display: none;
}
