/**
 * OFFICELESS OS - COMPONENT LIBRARY & MODULE STYLING
 * Part 2: Buttons, Forms, Window Manager, Module Tiles, Navigation
 */

/* ═══════════════ BUTTON LIBRARY ═══════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-default);
}

.btn--primary {
    background: var(--ofls-purple);
    color: white;
}

.btn--primary:hover {
    background: #5816CC;
    box-shadow: var(--shadow-glow);
}

.btn--secondary {
    background: transparent;
    border-color: var(--neutral-300);
    color: var(--neutral-600);
}

.btn--secondary:hover {
    background: var(--neutral-100);
    border-color: var(--neutral-400);
}

.btn--ghost {
    background: transparent;
    color: var(--portal-accent);
}

.btn--ghost:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn--glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-color: var(--glass-border);
}

.btn--icon {
    padding: var(--space-2);
    border-radius: var(--radius-lg);
}

.btn--lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
}

.btn--sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

/* ═══════════════ FORM ELEMENTS ═══════════════ */
.input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    background: var(--glass-bg);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-xl);
    transition: all var(--duration-fast) var(--ease-default);
}

.input:focus {
    outline: none;
    border-color: var(--ofls-purple);
    box-shadow: 0 0 0 3px rgba(108, 29, 255, 0.1);
}

.input--glass {
    backdrop-filter: var(--glass-blur);
    border-color: var(--glass-border);
}

.textarea {
    min-height: 120px;
    resize: vertical;
}

.select {
    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 fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--neutral-300);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-default);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    transition: transform var(--duration-fast) var(--ease-spring);
}

.toggle.active {
    background: var(--ofls-purple);
}

.toggle.active::after {
    transform: translateX(20px);
}

/* ═══════════════ WINDOW MANAGER ═══════════════ */
.wm-window {
    position: absolute;
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    min-width: 320px;
    min-height: 200px;
}

.wm-window--focused {
    box-shadow: var(--shadow-2xl), 0 0 0 2px var(--ofls-purple);
}

.wm-window__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--window-header);
    padding: 0 var(--space-4);
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid var(--glass-border);
    cursor: grab;
}

.wm-window__header:active {
    cursor: grabbing;
}

.wm-window__title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-700);
}

.wm-window__controls {
    display: flex;
    gap: var(--space-2);
}

.wm-window__control {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
}

.wm-window__control--close {
    background: #FF5F56;
}

.wm-window__control--minimize {
    background: #FFBD2E;
}

.wm-window__control--maximize {
    background: #27C93F;
}

.wm-window__content {
    flex: 1;
    overflow: auto;
    padding: var(--space-4);
}

/* ═══════════════ MODULE TILES ═══════════════ */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-6);
}

.module-tile {
    display: flex;
    flex-direction: column;
    padding: var(--space-6);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    transition: all var(--duration-normal) var(--ease-default);
    cursor: pointer;
}

.module-tile:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.module-tile__icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--glass-bg), rgba(255, 255, 255, 0.9));
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.module-tile__title {
    font-family: var(--font-serif);
    font-size: var(--text-lg);
    color: var(--neutral-800);
    margin-bottom: var(--space-2);
}

.module-tile__desc {
    font-size: var(--text-sm);
    color: var(--neutral-500);
    line-height: var(--leading-relaxed);
}

.module-tile__status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-4);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.module-tile__status--active {
    color: var(--color-success);
}

.module-tile__status--pending {
    color: var(--color-warning);
}

.module-tile__status--error {
    color: var(--color-error);
}

/* ═══════════════ NAVIGATION ═══════════════ */
.nav-sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: var(--space-4);
    overflow-y: auto;
}

.nav-section {
    margin-bottom: var(--space-6);
}

.nav-section__title {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-widest);
    color: var(--neutral-400);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-xl);
    color: var(--neutral-600);
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease-default);
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--neutral-800);
}

.nav-item--active {
    background: var(--portal-primary-bg);
    color: var(--portal-accent);
    font-weight: 600;
}

.nav-item__icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

.nav-item__label {
    font-size: var(--text-sm);
}

.nav-item__badge {
    margin-left: auto;
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 700;
    background: var(--color-error);
    color: white;
    border-radius: var(--radius-full);
}

/* ═══════════════ HEADER ═══════════════ */
.global-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
}

.header__logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-family: var(--font-serif);
    font-size: var(--text-xl);
    font-weight: 400;
    color: var(--portal-accent);
}

.header__search {
    flex: 1;
    max-width: 400px;
    margin: 0 var(--space-8);
}

.header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

/* ═══════════════ TICKER BAR ═══════════════ */
.ticker {
    height: var(--ticker-height);
    background: var(--neutral-900);
    color: var(--neutral-100);
    display: flex;
    align-items: center;
    overflow: hidden;
    font-size: var(--text-xs);
    font-family: var(--font-mono);
}

.ticker__content {
    display: flex;
    gap: var(--space-8);
    animation: ticker-scroll 60s linear infinite;
}

@keyframes ticker-scroll {
    0% {
        transform: translateX(100%);
    }

    100% {
        transform: translateX(-100%);
    }
}

.ticker__item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    white-space: nowrap;
}

.ticker__value--up {
    color: var(--color-success);
}

.ticker__value--down {
    color: var(--color-error);
}