/* Butler - Mobile-first CSS */

/* CSS Reset and Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --success: #10b981;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;

    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3 {
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }

p { margin-bottom: 0.5rem; }

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-large {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.125rem;
}

.btn-auth {
    width: 100%;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.btn-auth:hover {
    background: var(--bg);
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card h2 {
    margin-bottom: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-hint {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

/* Messages */
.error-message {
    background: #fef2f2;
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
}

.success-text {
    color: var(--success);
}

.warning-text {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

.hint {
    color: var(--text-light);
    margin-bottom: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 1rem;
}

/* Landing Page */
.landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.landing-header {
    text-align: center;
    padding: 3rem 1.5rem 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
}

.landing-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.tagline {
    opacity: 0.9;
    font-size: 1.125rem;
}

.landing-main {
    flex: 1;
    padding: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.hero {
    text-align: center;
    padding: 2rem 0;
}

.hero-icon {
    color: var(--primary);
    margin-bottom: 1rem;
}

.hero h2 {
    margin-bottom: 0.75rem;
}

.features {
    display: grid;
    gap: 1rem;
    margin: 2rem 0;
}

.feature {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.feature h3 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.cta {
    text-align: center;
    padding: 2rem 0;
}

.landing-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Auth Page */
.auth-page {
    min-height: 100vh;
    background: var(--bg);
}

.auth-header {
    padding: 1rem 1.5rem;
}

.back-link {
    color: var(--text-light);
    font-size: 0.875rem;
}

.auth-header h1 {
    text-align: center;
    margin-top: 0.5rem;
}

.auth-main {
    padding: 1.5rem;
    max-width: 400px;
    margin: 0 auto;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
}

.divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: var(--text-light);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    padding: 0 1rem;
    font-size: 0.875rem;
}

.email-form input {
    margin-bottom: 0.75rem;
}

/* Dashboard */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.app-header h1 {
    font-size: 1.25rem;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: var(--text-light);
    font-size: 0.875rem;
}

.dashboard-main,
.apartment-main,
.settings-main {
    padding: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

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

.section-header h2 {
    margin: 0;
}

/* Apartments List */
.apartments-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.apartment-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.apartment-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

.apartment-card-info h3 {
    margin-bottom: 0.25rem;
}

.apartment-card-info p {
    font-size: 0.875rem;
    color: var(--text-light);
    margin: 0;
}

.apartment-card-arrow {
    color: var(--text-light);
    font-size: 1.25rem;
}

/* Tabs */
.tab-bar {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Passphrase Display */
.passphrase-section {
    text-align: center;
}

.passphrase-display {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    padding: 2rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.passphrase-words {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.passphrase-timer {
    font-size: 0.875rem;
    opacity: 0.9;
}

.passphrase-display.passphrase-used {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    animation: passphrase-used-fade 0.3s ease-in-out;
}

.passphrase-display.passphrase-used .passphrase-timer {
    display: none;
}

@keyframes passphrase-used-fade {
    from {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
    to {
        transform: scale(1);
    }
}

.usage-hint {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-top: 1rem;
}

/* Durable Passphrases */
.durable-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    cursor: pointer;
}

.durable-list.durable-hidden {
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.durable-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    color: var(--text-light);
}

.durable-reveal-hint {
    font-size: 0.75rem;
}

.durable-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-family: monospace;
}

.durable-hide-hint {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
    padding: 0.5rem;
}

.durable-item.used {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Info Lists */
.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.info-list dt {
    color: var(--text-light);
    font-size: 0.875rem;
}

.info-list dd {
    font-weight: 500;
}

/* Delegates List */
.delegates-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.delegate-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.delegate-info {
    font-size: 0.875rem;
}

.delegate-name {
    font-weight: 500;
}

.delegate-email {
    color: var(--text-light);
}

.delegate-pending .delegate-name {
    font-style: italic;
    color: var(--text-light);
}

/* Logs */
.logs-list {
    max-height: 300px;
    overflow-y: auto;
}

.log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.log-result {
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.log-result.success {
    background: #d1fae5;
    color: #065f46;
}

.log-result.failed {
    background: #fee2e2;
    color: #991b1b;
}

.log-result.forwarded {
    background: #fef3c7;
    color: #92400e;
}

.log-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Recordings */
.recordings-list {
    max-height: 400px;
    overflow-y: auto;
}

.recording-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.recording-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.recording-caller {
    font-size: 0.875rem;
    font-weight: 500;
}

.recording-duration {
    font-size: 0.75rem;
    color: var(--text-light);
    background: var(--bg);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
}

.recording-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.recording-download {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
}

.recording-download:hover {
    text-decoration: underline;
}

.recording-pending {
    font-size: 0.75rem;
    color: var(--text-light);
    font-style: italic;
}

.recording-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Danger Section */
.danger-section {
    border: 1px solid var(--danger);
    background: #fef2f2;
}

.danger-section h2 {
    color: var(--danger);
}

/* Phone Form */
.phone-form {
    margin-top: 1rem;
}

.check-icon {
    color: var(--success);
    margin-right: 0.5rem;
}

/* Responsive */
@media (min-width: 768px) {
    h1 { font-size: 2rem; }

    .landing-header {
        padding: 4rem 2rem 3rem;
    }

    .landing-header h1 {
        font-size: 3rem;
    }

    .features {
        grid-template-columns: repeat(3, 1fr);
    }

    .passphrase-words {
        font-size: 2.5rem;
    }
}
