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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.8;
    color: #333;
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3c72 100%);
    min-height: 100vh;
    /* Safe area for notched phones */
    padding-bottom: env(safe-area-inset-bottom);
}

.container {
    max-width: 700px;
    margin: 2rem auto;
    padding: 2rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    position: relative;
    min-height: 45px;
}

h1 {
    margin: 0;
    color: #2c3e50;
    font-size: 2rem;
    flex: 1;
    text-align: center;
    white-space: nowrap;
}

.settings-button {
    background: #2c5aa0;
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(44, 90, 160, 0.3);
}

.settings-button:hover {
    background: #1e3c72;
    transform: scale(1.05);
}

.subtitle {
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.manager-info {
    text-align: center;
    margin-bottom: 2rem;
}

.manager-badge {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    padding: 0.7rem 1.5rem;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 500;
    display: inline-block;
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.3);
}

/* Authorization Screen */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3c72 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.auth-container {
    background: white;
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 450px;
    width: 90%;
    text-align: center;
}

.auth-container h1 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: #7f8c8d;
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.auth-form {
    text-align: left;
}

.auth-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
}

.auth-form input[type="password"] {
    width: 100%;
    padding: 1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s ease;
}

.auth-form input[type="password"]:focus {
    outline: none;
    border-color: #2c5aa0;
}

.auth-form input[type="password"].error {
    border-color: #e74c3c;
    animation: shake 0.3s ease;
}

.auth-button {
    width: 100%;
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3c72 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(44, 90, 160, 0.4);
}

.auth-error {
    background: #ffe6e6;
    color: #e74c3c;
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.95rem;
}

.logout-button {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 0.5rem;
}

.logout-button:hover {
    background: #c0392b;
    transform: scale(1.02);
}

.required {
    color: #e74c3c;
    font-weight: bold;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

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

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
}

.close-button {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #95a5a6;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-button:hover {
    color: #e74c3c;
}

.modal-body {
    padding: 2rem;
}

.modal-body label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
}

.modal-body input[type="text"] {
    width: 100%;
    padding: 1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s ease;
}

.modal-body input[type="text"]:focus {
    outline: none;
    border-color: #2c5aa0;
}

.modal-note {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin: 0;
    font-style: italic;
}

.modal-footer {
    padding: 1rem 2rem 2rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.save-button {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3c72 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(44, 90, 160, 0.4);
}

.clear-button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-button:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.7);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.recording-section {
    text-align: center;
    margin-bottom: 2rem;
}

.record-button {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3c72 100%);
    color: white;
    border: none;
    padding: 1.5rem 3rem;
    border-radius: 60px;
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(44, 90, 160, 0.4);
}

.record-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(44, 90, 160, 0.5);
}

.record-button.recording {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    animation: pulse 1.5s infinite;
}

.record-icon {
    font-size: 1.8rem;
}

.recording-status {
    margin-top: 1.5rem;
    font-size: 1.1rem;
    color: #2c5aa0;
    font-weight: 500;
}


.conversation-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    /* Account for Safari toolbar */
    margin-bottom: max(1rem, env(safe-area-inset-bottom));
}

.conversation-section h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.conversation-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.conversation-item {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: white;
    border-radius: 15px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.bubble {
    padding: 1.2rem 1.5rem;
    border-radius: 20px;
    max-width: 85%;
    word-break: break-word;
    font-size: 1.15rem;
    margin-bottom: 0.3rem;
    line-height: 1.6;
}

.bubble.transcript {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3c72 100%);
    color: #fff;
    align-self: flex-start;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(44, 90, 160, 0.3);
    width: 100%;
    max-width: 100%;
    transition: all 0.3s ease;
}

.bubble.transcript.expandable {
    cursor: pointer;
    border: 2px solid transparent;
}

.bubble.transcript.expandable:hover {
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.bubble.transcript.expanded {
    background: linear-gradient(135deg, #1e3c72 0%, #2c5aa0 100%);
}

.timestamp {
    font-size: 0.95rem;
    color: #95a5a6;
    margin-bottom: 1rem;
    font-weight: 500;
}

.webhook-response {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: #fff;
    padding: 1.2rem 1.5rem;
    border-radius: 20px;
    margin-top: 1rem;
    font-size: 1.1rem;
    line-height: 1.6;
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.3);
}

.webhook-response h4 {
    margin: 0 0 0.8rem 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.response-content {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 10px;
    margin-top: 0.8rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.95rem;
}

.status-badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.status-success {
    background: #2ecc71;
    color: white;
}

.status-pending {
    background: #f39c12;
    color: white;
}

.status-error {
    background: #e74c3c;
    color: white;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Mobile optimizations - Small Android screens */
@media (max-width: 480px) {
    body {
        padding: 0;
        margin: 0;
    }
    
    .container {
        margin: 0;
        padding: 1rem;
        border-radius: 0;
        min-height: 100vh;
    }
    
    /* Compact header */
    .header-section {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
        margin-bottom: 0.75rem;
    }
    
    h1 {
        font-size: 1.5rem;
        text-align: left;
        line-height: 1.2;
    }
    
    /* Button row */
    .header-section .settings-button,
    .header-section .logout-button {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .settings-button {
        right: 7rem;
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .logout-button {
        right: 1rem;
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
        min-width: 75px;
    }
    
    .subtitle {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
        text-align: left;
    }
    
    /* Compact manager badge */
    .manager-info {
        margin-bottom: 1rem;
        text-align: left;
    }
    
    .manager-badge {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        display: block;
        word-break: break-word;
    }
    
    /* Large touch-friendly record button */
    .recording-section {
        margin-bottom: 1.5rem;
    }
    
    .record-button {
        width: 100%;
        padding: 1.2rem;
        font-size: 1.1rem;
        border-radius: 15px;
        justify-content: center;
    }
    
    .record-icon {
        font-size: 1.5rem;
    }
    
    .recording-status {
        font-size: 1rem;
        margin-top: 1rem;
    }
    
    /* Compact conversation section */
    .conversation-section {
        padding: 1rem;
        margin-top: 1rem;
        border-radius: 12px;
    }
    
    .conversation-section h2 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }
    
    .conversation-list {
        gap: 1rem;
    }
    
    .conversation-item {
        padding: 1rem;
        margin-bottom: 0.5rem;
        border-radius: 12px;
    }
    
    .timestamp {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }
    
    .bubble {
        padding: 0.9rem 1.1rem;
        font-size: 1rem;
        border-radius: 15px;
        line-height: 1.5;
    }
    
    .bubble.transcript {
        border-radius: 15px;
    }
    
    .webhook-response {
        padding: 1rem;
        margin-top: 0.75rem;
        font-size: 0.95rem;
        border-radius: 15px;
    }
    
    .webhook-response h4 {
        font-size: 1rem;
        margin-bottom: 0.6rem;
    }
    
    .response-content {
        font-size: 0.85rem;
        padding: 0.8rem;
    }
    
    .status-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.6rem;
    }
    
    /* Mobile-friendly modal */
    .modal-content {
        width: 95%;
        max-width: 100%;
        margin: 0.5rem;
        border-radius: 15px;
    }
    
    .modal-header {
        padding: 1rem 1.25rem 0.75rem;
    }
    
    .modal-header h3 {
        font-size: 1.2rem;
    }
    
    .modal-body {
        padding: 1.25rem;
    }
    
    .modal-body label {
        font-size: 0.95rem;
    }
    
    .modal-body input[type="text"] {
        padding: 0.9rem;
        font-size: 1rem;
        border-radius: 8px;
    }
    
    .modal-note {
        font-size: 0.85rem;
    }
    
    .modal-footer {
        padding: 0.75rem 1.25rem 1.25rem;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .save-button,
    .clear-button {
        width: 100%;
        padding: 0.9rem;
        font-size: 1rem;
    }
    
    /* Auth screen mobile */
    .auth-container {
        padding: 2rem 1.5rem;
        width: 90%;
    }
    
    .auth-container h1 {
        font-size: 1.8rem;
        text-align: center;
    }
    
    .auth-subtitle {
        font-size: 1rem;
    }
    
    .auth-form input[type="password"] {
        padding: 0.9rem;
        font-size: 1rem;
    }
    
    .auth-button {
        padding: 0.9rem 1.5rem;
        font-size: 1rem;
    }
}

/* Large phones (iPhone Pro Max, Galaxy S Ultra, etc) */
@media (min-width: 390px) and (max-width: 480px) {
    .container {
        padding: 1.25rem;
        margin: 0.5rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 0.95rem;
    }
    
    .conversation-section {
        padding: 1.25rem;
    }
}

/* Tablet optimizations */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .record-button {
        padding: 1.2rem 2rem;
        font-size: 1.2rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .record-button {
        border: 3px solid #000;
    }
    
    .bubble {
        border: 2px solid #000;
    }
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
