/* ---------- Base ---------- */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f4f5f7;
    color: #1f2328;
    line-height: 1.5;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.25rem;
}

/* ---------- Header / Footer ---------- */
.app-header {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.brand {
    display: inline-block;
    padding: 1rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2328;
    text-decoration: none;
}

.app-footer {
    margin-top: 3rem;
    padding: 1rem 0;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}

/* ---------- Layout ---------- */
.app-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
    align-items: start;
    margin-top: 1.5rem;
}

@media (max-width: 860px) {
    .app-grid {
        grid-template-columns: 1fr;
    }
}

.dialer-panel,
.log-panel {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.dialer-panel h1,
.log-panel h2 {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    font-weight: 600;
}

/* ---------- Alerts ---------- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.field-error {
    display: block;
    color: #991b1b;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* ---------- Display ---------- */
.display-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.display {
    width: 100%;
    font-size: 1.75rem;
    padding: 0.85rem 3rem 0.85rem 0.85rem;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    background: #f9fafb;
    text-align: center;
    letter-spacing: 0.02em;
}

.display:focus {
    outline: none;
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-backspace {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
}

.btn-backspace:hover {
    background: #f3f4f6;
    color: #1f2328;
}

/* ---------- Keypad ---------- */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.key {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0.9rem 0;
    background: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.12s, transform 0.05s;
    user-select: none;
}

.key:hover {
    background: #e5e7eb;
}

.key:active {
    background: #d1d5db;
    transform: scale(0.97);
}

.key .digit {
    font-size: 1.4rem;
    font-weight: 500;
    color: #1f2328;
}

.key .letters {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: #6b7280;
    min-height: 0.8rem;
}

/* ---------- Call button ---------- */
.btn-call {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.95rem;
    background: #16a34a;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, transform 0.05s;
}

.btn-call:hover {
    background: #15803d;
}

.btn-call:active {
    transform: scale(0.99);
}

.phone-icon {
    font-size: 1.15rem;
}

/* ---------- Call log ---------- */
.empty {
    color: #6b7280;
    font-style: italic;
}

.log-table-wrap {
    overflow-x: auto;
}

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.log-table th,
.log-table td {
    padding: 0.65rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid #f0f1f3;
    vertical-align: top;
}

.log-table th {
    font-weight: 600;
    color: #6b7280;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #fafafa;
}

.log-table tbody tr:hover {
    background: #fafbfc;
}

.mono {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9rem;
}

/* ---------- Status pills ---------- */
.status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    background: #e5e7eb;
    color: #374151;
    text-transform: capitalize;
}

.status-completed,
.status-in-progress {
    background: #dcfce7;
    color: #166534;
}

.status-queued,
.status-ringing,
.status-initiated {
    background: #dbeafe;
    color: #1e40af;
}

.status-failed,
.status-busy,
.status-no-answer,
.status-canceled {
    background: #fee2e2;
    color: #991b1b;
}

.err-msg {
    margin-top: 4px;
    font-size: 0.75rem;
    color: #991b1b;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inline-form {
    display: inline;
}

.btn-link {
    background: transparent;
    border: none;
    color: #2563eb;
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.btn-link:hover {
    background: #eff6ff;
}

/* ---------- Device status ---------- */
.device-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #374151;
    margin-bottom: 1rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9ca3af;
    flex-shrink: 0;
}

.status-dot.ready {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.status-dot.connecting,
.status-dot.ringing {
    background: #f59e0b;
    animation: pulse 1.1s infinite;
}

.status-dot.on-call {
    background: #3b82f6;
}

.status-dot.error {
    background: #ef4444;
}

.status-dot.offline {
    background: #9ca3af;
}

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

/* ---------- Incoming banner ---------- */
.incoming-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 10px;
    margin-bottom: 1rem;
    animation: pulse-bg 1.5s infinite;
}

@keyframes pulse-bg {
    0%, 100% { background: #fef3c7; }
    50% { background: #fde68a; }
}

.incoming-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.9rem;
}

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

.btn-accept,
.btn-reject {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-accept {
    background: #16a34a;
    color: white;
}

.btn-accept:hover { background: #15803d; }

.btn-reject {
    background: #dc2626;
    color: white;
}

.btn-reject:hover { background: #b91c1c; }

/* ---------- Call controls ---------- */
.call-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-hangup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.95rem;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-hangup:hover { background: #b91c1c; }

.btn-mute {
    width: 100%;
    padding: 0.65rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
}

.btn-mute:hover { background: #e5e7eb; }
