/* ============================================================
   app.css — PrintMyCheque Application Styles
   Uses Bootstrap 5 as base. Custom overrides here.
   See docs/07-UI-UX-DESIGN-SYSTEM.md for design tokens.
   ============================================================ */

/* ─── Google Font ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── Design Tokens ───────────────────────────────────────── */
:root {
    --color-primary:       #1A56DB;
    --color-primary-dark:  #1241B0;
    --color-danger:        #E02424;
    --color-success:       #057A55;
    --color-warning:       #C27803;
    --color-muted:         #6B7280;
    --color-bg:            #F3F4F6;
    --color-surface:       #FFFFFF;
    --color-border:        #E5E7EB;
    --sidebar-width:       240px;
    --header-height:       56px;
    --border-radius:       8px;
    --font-family:         'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-family);
    font-size: 0.875rem;
    background-color: var(--color-bg);
    color: #111827;
    margin: 0;
}

/* ─── App Layout ──────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: #1F2937;
    color: #F9FAFB;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.2s ease;
}

.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    height: var(--header-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
}

.app-content {
    flex: 1;
    padding: 1.5rem;
}

/* ─── Sidebar Navigation ──────────────────────────────────── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1rem 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #F9FAFB;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 0.5rem;
}

.sidebar-nav {
    padding: 0.5rem 0;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1rem;
    color: #D1D5DB;
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 6px;
    margin: 1px 8px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #F9FAFB;
}

.sidebar-nav-item.active {
    background: var(--color-primary);
    color: #FFFFFF;
}

.sidebar-nav-item i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6B7280;
    padding: 1rem 1rem 0.25rem;
}

/* ─── Cards ───────────────────────────────────────────────── */
.card {
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.card-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
}

.card-footer {
    background: #F9FAFB;
    border-top: 1px solid var(--color-border);
}

/* ─── Page Header ─────────────────────────────────────────── */
.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
}

.page-subtitle {
    font-size: 0.8125rem;
}

/* ─── Tables ──────────────────────────────────────────────── */
.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    font-size: 0.875rem;
}

.table-responsive {
    min-height: 700px;
}

/* ─── Badges ──────────────────────────────────────────────── */
.badge {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.3em 0.6em;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
}

.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-primary:hover {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

/* ─── Forms ───────────────────────────────────────────────── */
.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

.form-control, .form-select {
    font-size: 0.875rem;
    border-color: var(--color-border);
    border-radius: 6px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.form-text {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.invalid-feedback {
    font-size: 0.75rem;
}

/* ─── Empty State ─────────────────────────────────────────── */
.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state-icon {
    font-size: 3rem;
    color: #D1D5DB;
    margin-bottom: 1rem;
    display: block;
}

/* ─── Dashboard Metric Cards ──────────────────────────────── */
.metric-card .metric-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    flex-shrink: 0;
}

/* ─── Subscription Lock ───────────────────────────────────── */
.feature-locked {
    background: #F9FAFB;
    border: 1px dashed var(--color-border);
    border-radius: var(--border-radius);
    text-align: center;
    padding: 2rem;
}

/* ─── Auth Pages ──────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    background: var(--color-surface);
    padding: 2rem;
}

.auth-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    text-align: center;
    margin-bottom: 1.5rem;
}

/* ─── Responsive: Hide sidebar on small screens ───────────── */
@media (max-width: 767.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0;
    }
}

/* ============================================================
   Cheque Designer — see docs/14-CHEQUE-DESIGNER.md
   ============================================================ */
.designer-body {
    background: #E5E7EB;
    overflow: hidden;
    height: 100vh;
}

.designer-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.designer-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 52px;
    padding: 0 1rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.designer-toolbar-title {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.designer-toolbar-controls {
    display: flex;
    align-items: center;
    margin-left: 1rem;
}

.designer-toolbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.designer-body-row {
    display: flex;
    flex: 1;
    min-height: 0;
}

.designer-panel {
    width: 220px;
    flex-shrink: 0;
    background: var(--color-surface);
    overflow-y: auto;
    padding-bottom: 1rem;
}

.designer-palette {
    border-right: 1px solid var(--color-border);
}

.designer-properties {
    border-left: 1px solid var(--color-border);
    width: 260px;
}

.designer-panel-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    padding: 0.75rem 1rem 0.5rem;
    margin: 0;
}

.designer-palette-list {
    padding: 0 0.5rem;
}

.palette-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    cursor: pointer;
    color: #374151;
}

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

.palette-item.on-canvas {
    color: var(--color-muted);
}

.palette-item .bi {
    font-size: 0.8rem;
}

.designer-canvas-wrap {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem;
    background:
        linear-gradient(45deg, #f1f3f5 25%, transparent 25%),
        linear-gradient(-45deg, #f1f3f5 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f1f3f5 75%),
        linear-gradient(-45deg, transparent 75%, #f1f3f5 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.designer-canvas {
    position: relative;
    background: #FFFFFF;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    flex-shrink: 0;
}

.designer-canvas.show-grid {
    background-image:
        linear-gradient(to right, rgba(26,86,219,0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(26,86,219,0.08) 1px, transparent 1px);
}

.cheque-field {
    position: absolute;
    box-sizing: border-box;
    border: 1px dashed rgba(26,86,219,0.5);
    background: rgba(26,86,219,0.06);
    overflow: hidden;
    white-space: normal;
    overflow-wrap: break-word;
    cursor: move;
    user-select: none;
    display: flex;
    align-items: center;
    padding: 0 2px;
    color: #111827;
}

.cheque-field.selected {
    border: 2px solid var(--color-primary);
    background: rgba(26,86,219,0.12);
    z-index: 5;
}

.cheque-field.locked {
    cursor: not-allowed;
    border-style: solid;
    border-color: var(--color-muted);
}

.cheque-field.not-visible {
    opacity: 0.35;
}

.cheque-field .field-label {
    pointer-events: none;
    font-size: 9px;
    line-height: 1;
}

.cheque-field .resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    right: -4px;
    bottom: -4px;
    background: var(--color-primary);
    border-radius: 2px;
    cursor: nwse-resize;
    display: none;
}

.cheque-field.selected .resize-handle {
    display: block;
}

.toggle-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.small-screen-warning {
    margin-bottom: 0 !important;
}

@media (max-width: 1023.98px) {
    .small-screen-warning.d-none {
        display: block !important;
    }
}
