/* reusable components - buttons, cards, forms, tables, badges, alerts, etc */

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
}

a.btn:hover {
    color: inherit;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-darkest);
}

.btn-primary:hover {
    background: #d4d4d4;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.btn-secondary {
    background: var(--bg-dark);
    color: var(--text-primary);
    border-color: var(--border-default);
}

.btn-secondary:hover {
    background: var(--bg-light);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

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

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.btn-block {
    width: 100%;
}

/* Special Emerald Button for landing pages */
.btn-emerald {
    background: var(--accent);
    color: #000;
    box-shadow: var(--shadow-glow);
}

.btn-emerald:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.3);
}

/* ============ CARDS ============ */
.card {
    background: var(--bg-dark);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-md);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.card-header h2,
.card-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* stat cards for dashboards */
.stat-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card .stat-value {
    font-size: 2.25rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.stat-card .stat-change {
    font-size: 0.75rem;
    color: var(--success);
    font-weight: 500;
}

.stat-card .stat-icon {
    display: none;
}

/* ============ FORMS ============ */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.6rem 0.875rem;
    background: var(--bg-darkest);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-tertiary);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--text-primary);
    outline: none;
    box-shadow: 0 0 0 1px var(--text-primary);
}

.form-input.error {
    border-color: var(--danger);
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.5rem;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

.form-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='%23A1A1AA' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    padding-right: 2.5rem;
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.form-check input[type="checkbox"] {
    appearance: none;
    width: 1rem;
    height: 1rem;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    /* subtle small radius */
    background-color: var(--bg-darkest);
    display: grid;
    place-content: center;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.form-check input[type="checkbox"]:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.form-check input[type="checkbox"]::before {
    content: "";
    width: 0.65em;
    height: 0.65em;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
    transform: scale(0);
    transform-origin: bottom left;
    transition: 120ms transform ease-in-out;
    background-color: var(--bg-darkest);
    /* tick color */
}

.form-check input[type="checkbox"]:checked {
    background-color: var(--text-primary);
    border-color: var(--text-primary);
    box-shadow: none;
}

.form-check input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.form-check input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg-darkest), 0 0 0 4px var(--text-primary);
}

/* ============ TABLES ============ */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    background: var(--bg-dark);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    padding: 0.875rem 1.25rem;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-light);
}

.table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: var(--bg-light);
}

/* ============ BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.2);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.2);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
    border-color: rgba(59, 130, 246, 0.2);
}

.badge-teal {
    background: var(--accent-glow);
    color: var(--accent);
    border-color: rgba(16, 185, 129, 0.3);
}

.badge-neutral {
    background: var(--bg-light);
    color: var(--text-secondary);
    border-color: var(--border-default);
}

/* ============ ALERTS ============ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: var(--space-lg);
    border: 1px solid var(--border-default);
    background: var(--bg-light);
}

.alert-success {
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.alert-danger {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.alert-warning {
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

.alert-info {
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--info);
}

/* ============ MODAL ============ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-dark);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: var(--space-xl);
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ============ PAGE HEADER ============ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.04em;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: transparent;
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-default);
}

.empty-state h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ============ PRICING ============ */
.pricing-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    align-items: stretch;
}

.pricing-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 3rem 2rem;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.pricing-card.featured {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    transform: translateY(-8px);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.05) 0%, transparent 100%);
}

.pricing-card:not(.featured):hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.pricing-card-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-gradient);
    color: var(--bg-darkest);
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.25rem 1rem;
    border-radius: var(--radius-full);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    white-space: nowrap;
}

.pricing-card-header {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-subtle);
}

.pricing-card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.pricing-price {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.price-amount {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.04em;
}

.price-period {
    font-size: 0.95rem;
    color: var(--text-tertiary);
}

.pricing-features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2.5rem;
    list-style: none;
    padding: 0;
    flex: 1;
}

.pricing-features li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.pricing-features li::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}