:root {
    --bg-primary: #1a1d23;
    --bg-secondary: #212529;
    --bg-card: #2b3035;
    --border-color: #495057;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --accent: #0d6efd;
    --accent-hover: #0b5ed7;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: .875rem;
}

.navbar {
    background-color: var(--bg-secondary) !important;
}

.card {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

.card-header {
    background-color: rgba(255,255,255,.05);
    border-bottom-color: var(--border-color);
}

.card-footer {
    background-color: rgba(255,255,255,.03);
    border-top-color: var(--border-color);
}

.table {
    color: var(--text-primary);
    margin-bottom: 0;
}

.table-secondary {
    --bs-table-bg: #2b3035;
    --bs-table-color: var(--text-primary);
}

.table-dark {
    --bs-table-bg: var(--bg-card);
}

.form-control, .form-select {
    background-color: #1a1d23;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    background-color: #1a1d23;
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 .2rem rgba(13,110,253,.15);
}

.input-group-text {
    background-color: #1a1d23;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #1a1d23 0%, #0d1117 100%);
}

.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    white-space: nowrap;
}

.sortable:hover {
    background-color: rgba(13,110,253,.1);
}

.sortable .sort-icon {
    margin-left: 4px;
    opacity: .4;
}

.sortable.active .sort-icon {
    opacity: 1;
    color: var(--accent);
}

.badge-type {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.badge-saliente {
    background-color: var(--danger);
    color: #fff;
}

.badge-entrante {
    background-color: var(--success);
    color: #fff;
}

.badge-entrante_sip, .badge-saliente_sip {
    background-color: var(--accent);
    color: #fff;
}

.pagination {
    margin-bottom: 0;
}

.page-link {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
    padding: .25rem .6rem;
    font-size: .8rem;
}

.page-link:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.page-item.active .page-link {
    background-color: var(--accent);
    border-color: var(--accent);
}

.page-item.disabled .page-link {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-secondary);
    opacity: .5;
}

audio {
    height: 36px;
    border-radius: 4px;
}

audio::-webkit-media-controls-panel {
    background-color: #1a1d23;
}

.modal-content {
    border-color: var(--border-color);
}

.modal-header {
    border-bottom-color: var(--border-color);
}

.modal-footer {
    border-top-color: var(--border-color);
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast-custom {
    min-width: 300px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: .875rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
    animation: slideIn .3s ease;
}

.toast-custom.success {
    background-color: var(--success);
    color: #fff;
}

.toast-custom.error {
    background-color: var(--danger);
    color: #fff;
}

.toast-custom.info {
    background-color: var(--accent);
    color: #fff;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.phone-number {
    font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: .5px;
}

.stat-card {
    text-align: center;
    padding: 1.2rem;
    border-radius: 8px;
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border-color);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-card .stat-label {
    font-size: .75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.audio-btn-group {
    display: flex;
    gap: 4px;
}

.audio-btn-group .btn {
    padding: 2px 8px;
    font-size: .75rem;
    line-height: 1.4;
}

tr.row-selected {
    background-color: rgba(13,110,253,.15) !important;
}

.form-label {
    margin-bottom: .2rem;
    font-size: .75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .3px;
}

@media (max-width: 768px) {
    .container-fluid {
        padding-left: .5rem;
        padding-right: .5rem;
    }
    .audio-btn-group {
        flex-direction: column;
    }
    .table {
        font-size: .78rem;
    }
}

#statsBody .stat-card {
    transition: transform .2s;
}

#statsBody .stat-card:hover {
    transform: translateY(-2px);
}

.info-popover-container {
    position: relative;
}

.info-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #2b3035;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
    z-index: 999;
    min-width: 260px;
    white-space: nowrap;
}

.info-popover .popover-header {
    padding: 8px 12px;
    font-size: .75rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    background: rgba(255,255,255,.05);
    border-radius: 8px 8px 0 0;
    word-break: break-all;
    white-space: normal;
}

.info-popover .popover-body {
    padding: 8px 12px;
}

.info-popover .popover-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 2px 0;
    font-size: .78rem;
}

.info-popover .popover-row span:first-child {
    color: var(--text-secondary);
}

.info-popover .popover-row span:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

.info-popover::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border-color);
}

.floating-player {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    background: #2b3035;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.6);
    width: 340px;
    cursor: move;
    user-select: none;
    animation: fpSlideIn .3s ease;
}

@keyframes fpSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.floating-handle {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 6px auto;
    width: 40px;
    cursor: move;
}

.floating-body {
    padding: 4px 12px 10px;
    cursor: default;
}

.floating-top {
    display: flex;
    align-items: center;
    gap: 2px;
}

.fp-track-info {
    min-width: 0;
}

.fp-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.fp-control-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fp-slider {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--border-color);
    outline: none;
    cursor: pointer;
}

.fp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

.fp-volume-slider {
    width: 60px;
}

.fp-seek-slider {
    width: 100%;
}

.fp-speed-select {
    background: #1a1d23;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    font-size: .65rem;
    padding: 1px 4px;
    cursor: pointer;
    outline: none;
}

.fp-speed-select:focus {
    border-color: var(--accent);
}

#infoModalBody .info-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: .85rem;
    border-bottom: 1px solid rgba(255,255,255,.05);
}

#infoModalBody .info-row:last-child {
    border-bottom: none;
}

#infoModalBody .info-row span:first-child {
    color: var(--text-secondary);
}

#infoModalBody .info-row span:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

.floating-phone {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    background: #2b3035;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.6);
    width: 220px;
    padding: 8px;
    cursor: move;
    user-select: none;
    animation: fpSlideIn .3s ease;
}

.fp-handle {
    height: 22px;
    background: var(--border-color);
    border-radius: 6px 6px 0 0;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}
.fp-handle::after {
    content: '';
    display: block;
    width: 30px;
    height: 4px;
    background: rgba(255,255,255,.3);
    border-radius: 2px;
}

.fp-status {
    text-align: center;
    margin-bottom: 4px;
}

.phone-display {
    background: #1a1d23;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 6px;
    min-height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.phone-number-display {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 1.2rem;
    letter-spacing: 2px;
    color: #8AFFB4;
    word-break: break-all;
    text-align: center;
}

.phone-call-timer {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: .85rem;
    color: var(--warning);
}

.phone-dialpad {
    margin-bottom: 6px;
}

.dialpad-row {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.dialpad-btn {
    flex: 1;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #1a1d23;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}

.dialpad-btn:hover {
    background: var(--border-color);
}

.dialpad-btn:active {
    background: var(--accent);
}

.phone-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 2px;
}

.phone-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform .15s, opacity .15s;
}

.phone-btn:active {
    transform: scale(.92);
}

.phone-btn-call {
    background: var(--success);
    color: #fff;
}

.phone-btn-call:disabled {
    opacity: .4;
    cursor: default;
}

.phone-btn-hangup {
    background: var(--danger);
    color: #fff;
}

.phone-btn-mute {
    background: var(--warning);
    color: #000;
}

.phone-btn-mute.active {
    background: var(--danger);
    color: #fff;
}

@media (max-width: 576px) {
    .mini-player-content {
        min-width: auto;
        max-width: 90vw;
    }
    .floating-phone {
        width: 190px;
    }
}
