/* portal.css - TimeQuorum Portal Styling */

:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #10B981;
    --danger-color: #EF4444;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --bg-light: #F9FAFB;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.container {
    width: min(480px, calc(100vw - 32px));
    padding: 20px;
}

.container--wide {
    width: min(640px, calc(100vw - 32px));
}

.card {
    width: 100%;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.card--wide {
    max-width: 640px;
    padding: 32px;
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.logo p {
    font-size: 14px;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group input:disabled {
    background-color: var(--bg-light);
    cursor: not-allowed;
}

.btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

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

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

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-light);
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

.alert-success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #6EE7B7;
}

.alert-info {
    background-color: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #93C5FD;
}

.text-center {
    text-align: center;
}

.text-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
}

.text-link:hover {
    text-decoration: underline;
}

.divider {
    margin: 24px 0;
    text-align: center;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--border-color);
}

.divider span {
    background-color: white;
    padding: 0 12px;
    font-size: 14px;
    color: var(--text-secondary);
    position: relative;
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
}

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

/* Tenant Grid */
.tenant-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}

.tenant-card {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.tenant-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.tenant-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.tenant-card .subdomain {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.tenant-card .meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-free {
    background-color: #E5E7EB;
    color: #4B5563;
}

.badge-starter {
    background-color: #DBEAFE;
    color: #1E40AF;
}

.badge-professional {
    background-color: #DDD6FE;
    color: #5B21B6;
}

.badge-enterprise {
    background-color: #FCE7F3;
    color: #9F1239;
}

.badge-owner {
    background-color: #FEF3C7;
    color: #92400E;
}

.badge-admin {
    background-color: #D1FAE5;
    color: #065F46;
}

.badge-member {
    background-color: #E5E7EB;
    color: #4B5563;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state img {
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 480px) {
    body {
        align-items: flex-start;
    }

    .container {
        padding: 12px;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .card {
        padding: 24px 16px;
        border-radius: 8px;
    }

    .card--wide {
        padding: 24px 16px;
    }

    .form-group input {
        font-size: 16px; /* prevent iOS zoom */
    }

    .btn {
        font-size: 15px;
    }
}

/* Hide element utility */
.hidden {
    display: none !important;
}

/* Auth page layout (login, register, tenants) */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-nav {
    padding: 16px 24px;
    display: flex;
    align-items: center;
}

.auth-logo {
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-decoration: none;
    letter-spacing: -0.5px;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-logo:hover { opacity: 0.85; }

.auth-page .container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.auth-footer {
    padding: 20px 24px;
    text-align: center;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

.auth-footer a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.15s;
}

.auth-footer a:hover { color: white; }

/* Tenants page */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
}
.page-header-left h1 { font-size: 22px; }
.page-header-left p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.page-header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}
.tenant-card { position: relative; }
.tenant-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-sm-primary { background: var(--primary-color); color: white; }
.btn-sm-primary:hover { background: var(--primary-hover); }
.btn-sm-outline { background: white; color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-sm-outline:hover { background: var(--bg-light); border-color: #aaa; }
.usage-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}
.usage-label { width: 60px; flex-shrink: 0; }
.usage-bar-wrap { flex: 1; background: #e5e7eb; border-radius: 4px; height: 6px; overflow: hidden; }
.usage-bar { height: 100%; background: var(--primary-color); border-radius: 4px; transition: width 0.3s; }
.usage-bar.warn { background: #f59e0b; }
.usage-bar.danger { background: #ef4444; }
.usage-count { width: 60px; text-align: right; flex-shrink: 0; }

@media (max-width: 600px) {
    .page-header { flex-wrap: wrap; }
    .page-header-actions { width: 100%; justify-content: flex-end; }
    .tenant-card-actions { flex-wrap: wrap; }
}

/* Profile nav widget */
.profile-nav {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: 1.5px solid transparent;
    border-radius: 40px;
    padding: 5px 12px 5px 5px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    margin-top: 6px;
    text-align: left;
}
.profile-nav:hover, .profile-nav:focus {
    background: rgba(79, 70, 229, 0.07);
    border-color: var(--primary-color);
    outline: none;
}
.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.profile-nav-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}
.profile-nav-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.profile-nav-email {
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profile-nav-icon {
    font-style: normal;
    font-size: 14px;
    color: var(--text-secondary);
    margin-left: 2px;
}
@media (max-width: 600px) {
    .profile-nav-info { display: none; }
    .profile-nav { padding: 5px; }
}

/* Data table used in Global Settings / Email Templates */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead tr {
    border-bottom: 2px solid var(--border-color);
    text-align: left;
}
.data-table th {
    padding: 8px 10px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.data-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.data-table tbody tr:hover {
    background: var(--bg-light);
}
