@import url('kontem-ui.css');

:root {
    --portal-sidebar-width: var(--kontem-sidebar-width);
    --portal-sidebar-collapsed-width: 4.5rem;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body.portal-app {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--kontem-bg);
    color: var(--kontem-text);
}

body.portal-app.portal-sidebar-collapsed {
    --portal-sidebar-width: var(--portal-sidebar-collapsed-width);
}

.portal-shell {
    display: flex;
    min-height: 100dvh;
}

.portal-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 40;
    display: flex;
    width: var(--portal-sidebar-width);
    flex-direction: column;
    border-inline-end: 1px solid var(--kontem-border);
    background: var(--kontem-sidebar-bg);
    transition: width 0.2s ease, transform 0.2s ease;
}

.portal-sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 4rem;
    padding-inline: 1rem;
    border-bottom: 1px solid var(--kontem-border);
}

.portal-logo {
    height: 2.5rem;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.portal-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}

.portal-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: 0.5rem;
    color: #44403c;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.portal-nav-link:hover {
    background: #f5f5f4;
    color: var(--kontem-text);
}

.portal-nav-link.is-active {
    background: var(--kontem-primary-soft);
    color: var(--kontem-primary-text);
}

.portal-nav-icon {
    display: inline-flex;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.portal-nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.portal-sidebar-collapsed .portal-nav-label,
body.portal-sidebar-collapsed .portal-sidebar-footer-text,
body.portal-sidebar-collapsed .portal-logo-full {
    display: none;
}

body.portal-sidebar-collapsed .portal-logo-icon {
    display: block;
}

.portal-logo-icon {
    display: none;
    height: 2rem;
    width: 2rem;
    object-fit: contain;
}

.portal-sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--kontem-border);
}

.portal-user-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
}

.portal-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.portal-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
}

.portal-user-email {
    font-size: 0.75rem;
    color: var(--kontem-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-main {
    display: flex;
    min-height: 100dvh;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    margin-inline-start: var(--portal-sidebar-width);
    transition: margin-inline-start 0.2s ease;
}

.portal-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 4rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--kontem-border);
    background: rgb(255 255 255 / 0.92);
    backdrop-filter: blur(8px);
}

.portal-topbar-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.portal-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--kontem-border);
    border-radius: 0.5rem;
    background: #fff;
    color: #44403c;
    cursor: pointer;
}

.portal-icon-btn:hover {
    background: #f5f5f4;
}

.portal-content {
    flex: 1;
    padding: 1.5rem;
}

.portal-grid {
    display: grid;
    gap: 1.25rem;
}

@media (min-width: 960px) {
    .portal-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.portal-card {
    background: #fff;
    border: 1px solid var(--kontem-border);
    border-radius: 0.75rem;
    box-shadow: var(--kontem-shadow);
}

.portal-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--kontem-border);
}

.portal-card-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
}

.portal-card-body {
    padding: 1.25rem;
}

.portal-dl {
    display: grid;
    gap: 0.875rem;
    margin: 0;
}

.portal-dl-row {
    display: grid;
    gap: 0.25rem;
}

.portal-dl-row dt {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--kontem-muted);
}

.portal-dl-row dd {
    margin: 0;
    font-size: 0.9375rem;
}

.portal-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.portal-badge-success {
    background: #dcfce7;
    color: #166534;
}

.portal-badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.portal-badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.portal-badge-neutral {
    background: #f5f5f4;
    color: #57534e;
}

.portal-table-wrap {
    overflow-x: auto;
}

.portal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.portal-table th,
.portal-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--kontem-border);
    text-align: left;
    white-space: nowrap;
}

.portal-table th {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--kontem-muted);
    background: #fafaf9;
}

.portal-table tbody tr:hover {
    background: #fafaf9;
}

.portal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border: 0;
    border-radius: 0.5rem;
    background: var(--kontem-primary);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

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

.portal-btn-secondary {
    background: #fff;
    border: 1px solid var(--kontem-border);
    color: #44403c;
}

.portal-btn-secondary:hover {
    background: #f5f5f4;
}

.portal-btn-danger {
    background: #dc2626;
}

.portal-btn-danger:hover {
    background: #b91c1c;
}

.portal-btn-block {
    width: 100%;
}

.portal-alert {
    margin-bottom: 1rem;
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.portal-alert-success {
    background: #dcfce7;
    color: #166534;
}

.portal-alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.portal-form-group {
    margin-bottom: 1rem;
}

.portal-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #44403c;
}

.portal-input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #d6d3d1;
    border-radius: 0.5rem;
    background: #fff;
    font: inherit;
}

.portal-input:focus {
    outline: 2px solid rgb(217 119 6 / 0.25);
    border-color: var(--kontem-primary);
}

.portal-input-readonly {
    background: #f5f5f4;
    color: #78716c;
    cursor: default;
}

.portal-input-readonly:focus {
    outline: none;
    border-color: #d6d3d1;
}

.portal-link {
    color: #92400e;
    font-size: 0.875rem;
    text-decoration: none;
}

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

.portal-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--kontem-muted);
    font-size: 0.875rem;
}

/* Guest / login */
body.portal-guest {
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    background: var(--kontem-login-gradient);
    color: var(--kontem-text);
    min-height: 100dvh;
}

.portal-guest-shell {
    display: flex;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.portal-guest-card {
    width: 100%;
    max-width: 24rem;
    padding: 2.75rem 2.25rem;
    border: 1px solid rgb(28 25 23 / 0.06);
    border-radius: 1rem;
    background: #fff;
    box-shadow:
        0 1px 2px rgb(28 25 23 / 0.04),
        0 12px 32px rgb(28 25 23 / 0.08);
}

.portal-guest-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.75rem;
    text-align: center;
}

.portal-guest-brand img {
    height: 3.25rem;
    width: auto;
    margin-bottom: 0.75rem;
}

.portal-guest-brand p {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--kontem-muted);
}

.portal-guest-title {
    margin: 0 0 1.25rem;
    font-size: 1.125rem;
    font-weight: 600;
    text-align: center;
}

.portal-guest-subtitle {
    margin: -0.75rem 0 1.25rem;
    color: var(--kontem-muted);
    font-size: 0.875rem;
    text-align: center;
}

.portal-backdrop {
    display: none;
}

@media (max-width: 1023px) {
    .portal-sidebar {
        transform: translateX(-100%);
    }

    body.portal-mobile-open .portal-sidebar {
        transform: translateX(0);
        width: var(--portal-sidebar-width);
    }

    body.portal-mobile-open .portal-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 30;
        background: rgb(28 25 23 / 0.35);
    }

    .portal-main {
        margin-inline-start: 0;
    }

    body.portal-sidebar-collapsed .portal-main {
        margin-inline-start: 0;
    }
}
