/* === COMPONENTS: Buttons, Forms, Cards, Badges, Tables === */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-btn);
    border: none;
    font-family: var(--font-heading);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--trans-base);
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.btn .icn {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--btn-primary);
    color: var(--txt-inverse);
    box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
    background: rgba(var(--c-primary), 0.85);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.12);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
    box-shadow: var(--shadow-light);
    transition-duration: 0.1s;
}

.btn-primary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-brand {
    background: var(--btn-brand);
    color: var(--txt-inverse);
    box-shadow: var(--shadow-btn);
}

.btn-brand:hover {
    background: rgba(var(--c-accent), 0.88);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -2px rgba(37, 99, 235, 0.25);
}

.btn-brand:active {
    transform: translateY(0) scale(0.98);
    transition-duration: 0.1s;
}

.btn-secondary {
    background: var(--btn-second);
    color: var(--txt-primary);
    border: 1px solid var(--bd-default);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--bd-hover);
}

.btn-secondary:active {
    transform: scale(0.98);
    transition-duration: 0.1s;
}

.btn-ghost {
    background: transparent;
    color: var(--txt-second);
    padding: 0.5rem 0.875rem;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--txt-primary);
}

.btn-ghost:active {
    transform: scale(0.98);
    transition-duration: 0.1s;
}

.btn-sm {
    padding: 0.4375rem 1rem;
    font-size: 0.8125rem;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--txt-second);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--trans-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--txt-primary);
}

.btn-icon .icn {
    width: 18px;
    height: 18px;
}

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

.form-group label {
    display: block;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--txt-second);
    margin-bottom: 0.375rem;
    font-weight: 500;
}

.form-input,
.select-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-second);
    border: 1px solid var(--bd-default);
    border-radius: var(--radius-input);
    color: var(--txt-primary);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    transition: border-color var(--trans-base), box-shadow var(--trans-base);
    outline: none;
}

.form-input:focus,
.select-input:focus {
    border-color: var(--txt-primary);
    box-shadow: 0 0 0 3px rgba(var(--c-primary), 0.08);
}

.form-input::placeholder {
    color: var(--txt-tertiary);
}

textarea.form-input {
    resize: vertical;
    min-height: 60px;
}

.select-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23707070'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* Cards */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--bd-default);
    border-radius: var(--radius-card);
    padding: 1.75rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--trans-base), transform var(--trans-base), border-color var(--trans-base);
}

.card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: var(--bd-hover);
}

.card-title {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

.badge-pending {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.badge-progress {
    background: var(--blue-bg);
    color: var(--blue);
}

.badge-done {
    background: var(--green-bg);
    color: var(--green);
}

/* Progress bar */
.progress-bar {
    height: 6px;
    background: rgba(var(--c-primary), 0.08);
    border-radius: 3px;
    position: relative;
    flex: 1;
    min-width: 80px;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--txt-primary);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
    position: absolute;
    right: 0;
    top: -18px;
    font-size: 0.6875rem;
    color: var(--txt-second);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 0.75rem;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    color: var(--txt-second);
    border-bottom: 1px solid var(--bd-default);
    font-weight: 600;
    letter-spacing: 0;
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--bd-divider);
    font-size: 0.9375rem;
}

.data-table tr:hover td {
    background: rgba(var(--c-primary), 0.02);
}

/* Tabs */
.admin-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.5rem 1.125rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--txt-second);
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--trans-base);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.tab-btn .icn {
    width: 16px;
    height: 16px;
}

.tab-btn:hover {
    color: var(--txt-primary);
    border-bottom-color: var(--bd-hover);
}

.tab-btn.active {
    color: var(--txt-accent);
    border-bottom-color: rgba(var(--c-accent), 1);
    background: transparent;
}

/* Simple list */
.simple-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bd-divider);
}

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

.simple-list-item span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Access control lists (admin modal) */
.access-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

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

.access-section-header h3 {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
}

.access-count {
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--txt-primary);
    color: var(--bg-primary);
    padding: 1px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.access-section-actions {
    display: flex;
    gap: 0.25rem;
}

.access-list {
    border: 1px solid var(--bd-default);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0;
    max-height: 400px;
    overflow: auto;
    background: var(--bg-primary);
}

.access-group-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--txt-tertiary);
    padding: 0.5rem 0.75rem 0.15rem;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 1;
}

.access-item {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    transition: background 0.1s ease;
}

.access-item:hover {
    background: var(--bg-hover);
}

.access-item>span:first-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.access-item input[type="checkbox"] {
    cursor: pointer;
    flex-shrink: 0;
}

.access-item-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.perm-select {
    border: 1px solid var(--bd-default);
    border-radius: 10px;
    background: var(--bg-second);
    color: var(--fg-primary);
    padding: 2px 10px;
    font-size: 0.75rem;
    min-width: 0;
    cursor: pointer;
}

@media (max-width: 1100px) {
    .access-grid {
        grid-template-columns: 1fr;
    }
}

/* Dept color dot */
.dept-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}