/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 10px;
    opacity: 0.95;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Input Section */
.input-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

.input-group + .input-group {
    margin-top: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #555;
    font-size: 1.1rem;
}

.input-wrapper {
    display: flex;
    gap: 15px;
    align-items: center;
}

#passcodeInput, #mobileInput {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    outline: none;
}

#mobileInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#passcodeInput {
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

/* Buttons */
.btn {
    padding: 15px 25px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    min-width: 140px;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-call {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 7px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
    gap: 6px;
    min-width: auto;
}

.btn-call:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(76, 175, 80, 0.4);
}

.btn-whatsapp {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    padding: 7px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
    gap: 6px;
    min-width: auto;
}

.btn-whatsapp:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(37, 211, 102, 0.4);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.18);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 10px 18px;
    min-width: 0;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error */
.error {
    background: #ffebee;
    color: #c62828;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #c62828;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.error i {
    font-size: 1.5rem;
}

/* Speakers Section */
.contacts-section {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    margin-bottom: 30px;
}

/* The gradient sits on this row rather than the h2 so the buttons can sit beside it */
.contacts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 30px;
}

.contacts-section h2 {
    background: none;
    color: white;
    padding: 0;
    margin: 0;
    font-size: 1.5rem;
}

.contacts-list {
    padding: 10px 16px;
}

.contact-item {
    padding: 12px 4px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.3s ease;
}

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

.contact-item:hover {
    background-color: #f8f9fa;
}

.contact-name {
    font-size: 1.02rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 7px;
}

.contact-mobile {
    color: #666;
    font-size: 0.9rem;
}

.contact-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* A speaker may have several numbers; each gets its own Call/WhatsApp pair rather than
   a single pair that would have to guess which number to dial. */
.speaker-numbers {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.speaker-number {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* Second and later numbers are visually subordinate to the first */
.speaker-number + .speaker-number {
    padding-top: 8px;
    border-top: 1px dashed #eee;
}

/* No Speakers */
.no-contacts {
    text-align: center;
    padding: 60px 30px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    color: #666;
}

.no-contacts i {
    font-size: 4rem;
    color: #ccc;
    margin-bottom: 20px;
}

.no-contacts h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

    /* The title block used to eat most of a phone screen before any speaker showed */
    .header {
        margin-bottom: 22px;
    }

    .header h1 {
        font-size: 1.7rem;
    }

    .header h2 {
        font-size: 1.15rem;
    }

    .header p {
        font-size: 0.95rem;
    }

    .input-wrapper {
        flex-direction: column;
        gap: 15px;
    }

    .input-wrapper .btn {
        width: 100%;
    }

    /* overflow: clip instead of hidden -- hidden would make this a scroll container and
       silently kill the sticky header below. */
    .contacts-section {
        overflow: clip;
    }

    /* 58 entries is a long scroll, so the count and Logout stay in reach throughout. */
    .contacts-header {
        position: sticky;
        top: 0;
        z-index: 5;
    }
}

/* Phone layout: the number and both buttons no longer fit on one line, so each number
   becomes a stacked block with the two buttons splitting the row -- the same shape as
   the vv/ktm caller, which reads well one-handed. */
@media (max-width: 600px) {
    .contacts-list {
        padding: 8px 12px;
    }

    .contact-item {
        padding: 14px 2px;
    }

    .contact-name {
        font-size: 1.15rem;
        margin-bottom: 10px;
    }

    .contact-mobile {
        font-size: 0.98rem;
    }

    .speaker-numbers {
        gap: 14px;
    }

    .speaker-number {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .speaker-number + .speaker-number {
        padding-top: 14px;
    }

    .contact-actions {
        gap: 12px;
    }

    /* utils/common.css sets .btn { width: 100% } below 768px, which would stack the two
       buttons instead of letting them share the row. */
    .contact-actions .btn {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        padding: 12px 14px;
        font-size: 0.9rem;
        border-radius: 10px;
    }
}

@media (max-width: 480px) {
    .input-section {
        padding: 20px;
    }

    .contacts-header {
        padding: 12px 16px;
    }

    .contacts-section h2 {
        font-size: 1.15rem;
    }
}
