:root {
    --bg: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f3460;
    --primary: #e94560;
    --primary-hover: #c73650;
    --green: #00b894;
    --red: #e74c3c;
    --blue: #0984e3;
    --yellow: #fdcb6e;
    --gray: #636e72;
    --text: #ffffff;
    --text-dim: #a0a0a0;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* LOGIN */
#login-screen {
    justify-content: center;
    align-items: center;
}

.login-container {
    text-align: center;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
}

.login-container h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.subtitle {
    color: var(--text-dim);
    margin-bottom: 2rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form input {
    padding: 1rem;
    border: none;
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
}

.login-form input:focus {
    outline: 2px solid var(--primary);
}

.btn-primary {
    padding: 1rem;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover, .btn-primary:active {
    background: var(--primary-hover);
}

.btn-small {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

.btn-small:hover {
    background: var(--primary);
}

.error-msg {
    color: var(--red);
    min-height: 1.5rem;
    font-size: 0.9rem;
}

.result-msg {
    color: var(--green);
    min-height: 1.5rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* INTERCOM */
.intercom-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-card);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.user-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.role-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: var(--primary);
}

.role-badge.vip {
    background: var(--yellow);
    color: #000;
}

.role-badge.admin {
    background: var(--blue);
}

.production-name {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.intercom-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
    flex: 1;
    align-content: center;
}

.intercom-button {
    aspect-ratio: 2.5 / 1;
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    position: relative;
    overflow: hidden;
}

.intercom-button .btn-label {
    font-size: 1.1rem;
}

.intercom-button .btn-status {
    font-size: 0.7rem;
    opacity: 0.8;
}

.intercom-button.online {
    background: var(--green);
    color: #fff;
}

.intercom-button.busy {
    background: var(--red);
    color: #fff;
}

.intercom-button.active {
    background: var(--blue);
    color: #fff;
    box-shadow: 0 0 20px rgba(9, 132, 227, 0.5);
}

.intercom-button.vip-can-interrupt {
    border: 3px solid var(--yellow);
}

.intercom-button.offline {
    background: var(--gray);
    color: #aaa;
}

.intercom-button.unassigned {
    background: var(--bg-input);
    color: var(--text-dim);
}

.intercom-button:active {
    transform: scale(0.96);
}

.intercom-button.ptt-active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.6);
}

.call-status {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-dim);
    min-height: 2rem;
}

.announcement-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary);
    color: #fff;
    padding: 1rem;
    text-align: center;
    font-weight: bold;
    z-index: 100;
    display: none;
    animation: slideUp 0.3s ease;
}

.announcement-area.show {
    display: block;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ADMIN PANEL */
#admin-screen {
    padding: 1rem;
}

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

.admin-header h2 {
    color: var(--primary);
}

.admin-production-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-production-selector select {
    padding: 0.5rem;
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    border: none;
}

.admin-subscription {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-table th {
    background: var(--bg-card);
    padding: 0.75rem;
    text-align: left;
    position: sticky;
    top: 0;
}

.admin-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--bg-input);
}

.admin-table tr:hover {
    background: var(--bg-card);
}

.admin-table .online-yes { color: var(--green); }
.admin-table .online-no { color: var(--gray); }
.admin-table .vip-yes { color: var(--yellow); font-weight: bold; }

.action-btn {
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    margin: 0 2px;
}

.action-btn.edit { background: var(--blue); color: #fff; }
.action-btn.delete { background: var(--red); color: #fff; }
.action-btn.suspend { background: var(--yellow); color: #000; }
.action-btn.unsuspend { background: var(--green); color: #fff; }
.action-btn.password { background: var(--primary); color: #fff; }

/* Add person form */
.add-person-form {
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.add-person-form input {
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
}

.add-person-form label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Groups */
.groups-section {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.groups-list {
    min-width: 200px;
}

.groups-list h3 {
    margin-bottom: 1rem;
}

#groups-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 8px;
}

.groups-matrix {
    overflow-x: auto;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.modal-content label {
    display: block;
    margin: 0.5rem 0;
}

.modal-content input, .modal-content select, .modal-content textarea {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
    margin-top: 0.25rem;
}

.modal-content textarea {
    resize: vertical;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

#button-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

#button-modal-buttons select {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
}

/* Responsive */
@media (min-width: 768px) {
    .intercom-buttons {
        grid-template-columns: repeat(5, 1fr);
    }
    .intercom-button {
        aspect-ratio: 1.5 / 1.5;
    }
}

@media (min-width: 1200px) {
    .intercom-buttons {
        grid-template-columns: repeat(10, 1fr);
    }
    .intercom-button {
        aspect-ratio: 1 / 2;
    }
}
