/* ============================================================
   Tradilog — Custom Styles
   Complements Tailwind CSS CDN
   ============================================================ */

/* ── Typography ── */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[x-cloak] { display: none !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f8fafc; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Sidebar ── */
#sidebar-overlay {
    transition: opacity 0.28s ease;
}

/* ── Form inputs global ── */
.tl-input {
    display: block;
    width: 100%;
    height: 40px;
    padding: 0 0.75rem;
    font-size: 0.875rem;
    line-height: 40px;
    color: #111827;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}
/* Textareas grow naturally — no fixed height */
textarea.tl-input {
    height: auto;
    line-height: 1.5rem;
    padding: 0.5rem 0.75rem;
}
/* Custom select — hide native arrow, inject chevron */
select.tl-input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.625rem center;
    background-size: 1rem;
    cursor: pointer;
}
select.tl-input:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233b82f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
.tl-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.tl-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.10);
}
.tl-input:disabled {
    background-color: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

/* ── Upload Zone ── */
.upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: 0.75rem;
    background: #f9fafb;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    cursor: pointer;
}
.upload-zone:hover,
.upload-zone.drag-over {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

/* ── Calendar — base rules (detail styles are inline in calendar.php) ── */
.cal-day { min-height: 88px; }
.cal-day.other-month { opacity: 0.35; }

/* ── Toast Notifications ── */
#toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.125rem;
    border-radius: 0.625rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 260px;
    max-width: 380px;
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.toast.hiding {
    animation: toastOut 0.25s ease forwards;
}
.toast-success { background: #fff; border-left: 4px solid #16a34a; color: #15803d; }
.toast-error   { background: #fff; border-left: 4px solid #dc2626; color: #b91c1c; }
.toast-info    { background: #fff; border-left: 4px solid #2563eb; color: #1d4ed8; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(1.5rem) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to   { opacity: 0; transform: translateX(1.5rem) scale(0.95); }
}

/* ── Modal ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: backdropIn 0.2s ease forwards;
}
.modal-box {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 440px;
    animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes backdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.92) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Tabs ── */
.tab-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab-btn:hover { color: #374151; }
.tab-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* ── Stat Cards ── */
.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.875rem;
    padding: 1rem 1.125rem;
    transition: box-shadow 0.15s ease;
}
@media (min-width: 640px) {
    .stat-card { padding: 1.25rem 1.5rem; }
}
.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

/* Calendar cell responsive rules live inline in calendar.php */

/* ── Trade Cards ── */
.trade-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.875rem;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.trade-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.07);
    border-color: #d1d5db;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    height: 40px;
    padding: 0 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
    border: 1px solid transparent;
    outline: none;
    white-space: nowrap;
}
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(59,130,246,0.25); }
.btn-primary   { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; }
.btn-success   { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover { background: #15803d; }
.btn-danger    { background: #fff; color: #dc2626; border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; border-color: #ef4444; }
.btn-ghost     { background: transparent; color: #6b7280; border-color: transparent; }
.btn-ghost:hover { background: #f3f4f6; color: #374151; }
.btn-sm { height: 36px; padding: 0 0.75rem; font-size: 0.8125rem; }
.btn-lg { height: 48px; padding: 0 1.375rem; font-size: 0.9375rem; }

/* ── Checkboxes ── */
.check-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
    user-select: none;
}

.tl-check {
    appearance: none;
    -webkit-appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 0.3125rem;
    border: 1.5px solid #cbd5e1;
    background-color: #fff;
    display: inline-grid;
    place-content: center;
    vertical-align: middle;
    flex-shrink: 0;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.tl-check:hover,
.check-wrap:hover .tl-check {
    border-color: #94a3b8;
}
.tl-check:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.20);
}
.tl-check:checked {
    border-color: #2563eb;
    background-color: #2563eb;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 10.5L8.2 13.5L15 6.8' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 0.8rem 0.8rem;
}
.tl-check.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.10);
}

/* ── P/L Color Helpers ── */
.pl-positive { color: #16a34a; }
.pl-negative { color: #dc2626; }
.pl-pending  { color: #d97706; }

/* ── Form Validation ── */
.field-error {
    display: none;
    margin-top: 0.375rem;
    color: #dc2626;
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 500;
}
.field-error:not(:empty) { display: block; }

select.tl-input.error,
textarea.tl-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.10);
}

.form-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    line-height: 1.35rem;
    margin-bottom: 1rem;
}
.form-alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}
.form-alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
}
.form-alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
}
.form-alert ul { margin: 0.25rem 0 0 1.1rem; padding: 0; }
.form-alert li { list-style: disc; }
