/* Portal CSS - Main Stylesheet */

:root {
    --sw-color: purple;
    --sw-text-color: purple;
    --sw-button-color: purple;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    background: #f5f5f5;
}

a {
    color: black;
    text-decoration: none;
}
    a:hover {
        text-decoration: underline;
    }

/* Layout */
.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 20px;
    background: #fff;
    min-height: calc(100vh - 48px);
}
    .page h1 {
        margin: 0 0 16px 0;
        font-size: 20px;
        font-weight: 600;
    }
body.has-sw-menu .page {
    min-height: calc(100vh - 80px);  /* 48px menu + 32px sw menu */
}

/* Menu */
.menu {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    height: auto;
    min-height: 48px;
    background: var(--sw-color);
    padding: 0 16px;
}
    .menu .logo {
        height: 36px;
        width: auto;
        margin-right: 12px;
        flex-shrink: 0;
    }
    .menu nav {
        display: flex;
        flex-shrink: 0;
        height: 48px;
    }
        .menu nav a,
        .menu nav .current {
            display: flex;
            align-items: center;
            height: 100%;
            padding: 0 12px;
            color: var(--sw-text-color);
            text-decoration: none;
            background: rgba(255,255,255,0.1);
            margin-right: 2px;
        }
        .menu nav a:hover {
            background: rgba(255,255,255,0.25);
        }
        .menu nav .current {
            background: rgb(255 255 255 / 28%);
            font-weight: 600;
        }
    .menu .user-info {
        display: flex;
        align-items: center;
        margin-left: auto;
        height: 48px;
        color: var(--sw-text-color);
        font-size: 13px;
        flex-shrink: 0;
    }
        .menu .username {
            margin-right: 12px;
            opacity: 0.9;
            color: var(--sw-text-color);
        }
            .menu .username:hover {
                opacity: 1;
                text-decoration: underline;
            }
        .menu .logout {
            color: var(--sw-text-color);
            padding: 4px 10px;
            background: rgba(255,255,255,0.15);
            border-radius: 3px;
        }
            .menu .logout:hover {
                background: rgba(255,255,255,0.3);
                text-decoration: none;
            }

/* Software Type Menu (Admin) */
.menu-sw {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    height: 32px;
    background: var(--sw-color);
    filter: brightness(1.15);
    padding: 0 16px;
    gap: 2px;
}
    .menu-sw a,
    .menu-sw .current {
        display: flex;
        align-items: center;
        height: 100%;
        padding: 0 12px;
        color: var(--sw-text-color);
        text-decoration: none;
        background: rgba(255,255,255,0.1);
        font-size: 12px;
    }
    .menu-sw a:hover {
        background: rgba(255,255,255,0.25);
        text-decoration: none;
    }
    .menu-sw .current {
        background: rgb(255 255 255 / 28%);
        font-weight: 600;
    }

/* Page Actions */
.page-actions {
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
}
    .page-actions > * {
        margin-right: 8px;
        margin-bottom: 8px;
    }

/* Buttons - unified styling for button, input[type=submit], a.button */
button,
input[type="submit"],
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 14px;
    border: none;
    border-radius: 4px;
    background: var(--sw-button-color);
    color: var(--sw-text-color);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}
    button:hover,
    input[type="submit"]:hover,
    .button:hover {
        filter: brightness(1.1);
        text-decoration: none;
    }
    button:active,
    input[type="submit"]:active,
    .button:active {
        filter: brightness(0.95);
    }

/* Forms */
form {
    max-width: 400px;
}

.form-group {
    margin-bottom: 12px;
}
    .form-group > label {
        display: block;
        margin-bottom: 4px;
        font-weight: 500;
        color: #555;
    }
    .form-group input[type="text"],
    .form-group input[type="email"],
    .form-group input[type="password"],
    .form-group input[type="number"],
    .form-group select {
        width: 100%;
        height: 32px;
        padding: 0 8px;
        border: 1px solid #ccc;
        border-radius: 3px;
        font-size: 14px;
    }
    .form-group input:focus,
    .form-group select:focus {
        outline: none;
        border-color: var(--sw-color);
        box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
    }
    .form-group input[type="radio"] {
        margin-right: 6px;
    }
    .form-group > div label {
        display: inline-flex;
        align-items: center;
        margin-right: 16px;
        font-weight: normal;
        cursor: pointer;
    }

/* Messages */
.error {
    background: #fee;
    border: 1px solid #fcc;
    color: #c00;
    padding: 10px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
}

.notice {
    background: #efe;
    border: 1px solid #cfc;
    color: #060;
    padding: 10px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
}

/* Tables */
.filters {
    max-width: none;
}

.filter-controls {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}
    .filter-controls > * {
        margin-right: 12px;
    }
    .apply-filters {
        font-weight: 700;
    }
    .clear-filters {
        font-size: 13px;
        font-weight: 700;
    }

.table-scroll-container {
    width: 100%;
    overflow-x: auto;
    background:
        linear-gradient(to right, white, white),
        linear-gradient(to right, white, white),
        linear-gradient(to right, rgba(0,0,0,0.12), rgba(0,0,0,0)),
        linear-gradient(to left, rgba(0,0,0,0.12), rgba(0,0,0,0));
    background-position: left center, right center, left center, right center;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 15px 100%, 15px 100%;
    background-attachment: local, local, scroll, scroll;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
    .data-table th,
    .data-table td {
        padding: 8px 10px;
        text-align: left;
        border: 1px solid #ddd;
    }
    .data-table thead th {
        background: #f8f8f8;
        font-weight: 600;
    }
    .data-table tbody tr:hover {
        background: #fafafa;
    }
    .data-table .header-content {
        display: flex;
        align-items: center;
    }
        .data-table .header-content > * {
            margin-right: 6px;
        }
    .data-table .sort-arrow {
        display: inline-block;
        padding: 2px 4px;
        color: black;
        font-size: 12px;
        text-decoration: none;
        transition: transform 0.15s;
        border: 1px solid rgb(226, 226, 226);
        margin-left: 2px;
    }
        .data-table .sort-arrow:hover {
            text-decoration: underline;
            border: 1px solid black;
        }
        .data-table .sort-arrow.asc {
            transform: rotate(180deg);
        }
        .data-table .sort-arrow.desc {
            transform: rotate(0deg);
        }
        .data-table .sort-arrow.sorted {
            font-weight: bold;
        }

/* Action icons in tables */
.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 16px;
    color: #333;
    text-decoration: none;
    border-radius: 3px;
}
    .action-icon:hover {
        background-color: rgba(0, 0, 0, 0.08);
        text-decoration: none;
    }

.filter-row td {
    background: #fff;
    padding: 4px 6px;
}
    .filter-row input.filter {
        width: 100%;
        height: 28px;
        padding: 0 6px;
        border: 1px solid #ccc;
        border-radius: 3px;
        font-size: 12px;
    }

/* Pagination */
.pagination {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
    .pagination > * {
        margin-bottom: 8px;
    }

.pagination-info {
    font-size: 13px;
    color: #666;
}

.pagination-controls {
    display: flex;
    align-items: stretch;
    max-width: 100%;
}

.pagination-pages {
    display: flex;
    flex: 1;
    min-width: 0;
}

.pagination-nav,
.pagination-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background: var(--sw-button-color);
    color: var(--sw-text-color);
    text-decoration: none;
    font-size: 13px;
    border-left: 1px solid rgba(255,255,255,0.2);
}
    .pagination-nav:first-child{
        border-left: none;
        border-radius: 4px 0 0 4px;
    }
    .pagination-nav:last-child {
        border-radius: 0 4px 4px 0;
    }
    .pagination-nav:hover,
    .pagination-page:hover {
        filter: brightness(1.1);
        text-decoration: none;
    }
    .pagination-nav.disabled {
        opacity: 0.5;
        cursor: default;
        pointer-events: none;
    }
    .pagination-page.current {
        background: var(--sw-color);
        filter: brightness(0.9);
        font-weight: 600;
    }

.pagination-icon {
    font-size: 14px;
}

/* Login Page */
.login-container {
    max-width: 320px;
    margin: 60px auto 0 auto;
    padding: 24px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
}
    .login-container form {
        max-width: none;
    }
    .login-container p {
        margin: 12px 0 0 0;
        font-size: 13px;
        text-align: center;
    }

.login-header {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

/* Button group for login form */
.button-group {
    display: flex;
    gap: 8px;
}

/* Media Queries - Mobile */
@media (max-width: 768px) {
    .menu {
        flex-direction: column;
        height: auto;
        padding: 8px 12px;
    }
        .menu .logo {
            height: 28px;
            margin: 0 0 8px 0;
        }
        .menu nav {
            width: 100%;
            justify-content: center;
            height: 40px;
        }
            .menu nav a,
            .menu nav .current {
                padding: 0 10px;
                font-size: 13px;
            }
        .menu .user-info {
            width: 100%;
            justify-content: center;
            height: 36px;
            margin-left: 0;
            font-size: 12px;
        }
    .menu-sw {
        height: auto;
        min-height: 28px;
        flex-wrap: wrap;
        justify-content: center;
        padding: 4px 8px;
        gap: 4px;
    }
        .menu-sw a,
        .menu-sw .current {
            padding: 4px 8px;
            font-size: 11px;
            border-radius: 3px;
        }
    .page {
        padding: 12px;
    }
        .page h1 {
            font-size: 18px;
        }
    .data-table {
        font-size: 12px;
    }
        .data-table th,
        .data-table td {
            padding: 6px 8px;
        }
    .pagination-nav,
    .pagination-page {
        min-width: 27px;
        height: 44px;
        font-size: 12px;
    }
}
