/**
 * IPCE Platform — Custom Stylesheet
 * Built on Bootstrap 5.3
 * Keep this file thin — use Bootstrap utilities first.
 */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
    --ipce-sidebar-width: 250px;
    --ipce-navbar-height: 56px;
    --ipce-primary: #0d6efd;
    --ipce-transition: 0.2s ease;
}

/* ── Base ───────────────────────────────────────────────────── */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
    color: #212529;
    background-color: #f1f5f9;
}

/* ── Navbar ─────────────────────────────────────────────────── */
#mainNav {
    height: var(--ipce-navbar-height);
    position: sticky;
    top: 0;
    z-index: 1030;
}

#mainNav .navbar-brand {
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    border-radius: 10px;
    transition: box-shadow var(--ipce-transition);
}

.card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-control, .form-select {
    font-size: 0.875rem;
    border-radius: 8px;
    border-color: #dee2e6;
    padding: 0.5rem 0.75rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--ipce-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.form-label {
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
    color: #374151;
}

.input-group-text {
    border-radius: 8px 0 0 8px;
    border-color: #dee2e6;
    font-size: 0.9rem;
}

.is-invalid {
    border-color: #dc3545;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all var(--ipce-transition);
}

.btn-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0a5ad4 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0a58ca 0%, #0847b0 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.35);
}

.btn:active {
    transform: translateY(0);
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    border-radius: 10px;
    border: none;
    font-size: 0.875rem;
}

.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger   { background: #fee2e2; color: #991b1b; }
.alert-warning  { background: #fef3c7; color: #92400e; }
.alert-info     { background: #dbeafe; color: #1e40af; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table {
    font-size: 0.875rem;
}

.table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
}

.table tbody tr:hover {
    background-color: #f8faff;
}

/* ── Sidebar (for future use) ────────────────────────────────── */
.sidebar {
    width: var(--ipce-sidebar-width);
    height: calc(100vh - var(--ipce-navbar-height));
    position: sticky;
    top: var(--ipce-navbar-height);
    overflow-y: auto;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    padding: 1rem 0;
}

.sidebar .nav-link {
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    border-radius: 0;
    transition: all var(--ipce-transition);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar .nav-link:hover {
    background: #f3f4f6;
    color: var(--ipce-primary);
}

.sidebar .nav-link.active {
    background: #eff6ff;
    color: var(--ipce-primary);
    border-left: 3px solid var(--ipce-primary);
}

/* ── Utility ────────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.border-dashed   { border-style: dashed !important; }
.rounded-xl      { border-radius: 16px !important; }

/* ── Page transitions ────────────────────────────────────────── */
#mainContent {
    animation: fadeIn 0.15s ease;
    /*
     * A flex item's automatic minimum size is its content, so one wide table
     * stretched this column past the viewport and the whole page scrolled
     * sideways — header, sidebar and all. Pinning it to 0 makes the overflow
     * stay inside the table's own scroller.
     */
    min-width: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 767.98px) {
    .display-6 { font-size: 1.5rem; }

    /* Page headings sized for a phone rather than a 1440px column. */
    h4 { font-size: 1.15rem; }

    /*
     * iOS zooms the page in on focus of any field under 16px and does not zoom
     * back out, which strands the user on a half-visible form. The `-sm` fields
     * are included deliberately: the GST entry grids are built entirely from
     * them, so exempting them would leave the zoom exactly where it hurts. Only
     * the type scale changes here — `-sm` keeps its tighter padding.
     */
    .form-control, .form-select,
    .form-control-sm, .form-select-sm { font-size: 1rem; }

    /*
     * DataTables centres its length/search/info/paging blocks once they stack,
     * which leaves every control floating on its own axis while the table below
     * is flush left. Line them all up with the table instead.
     *
     * The `div.` qualifiers are not decoration — DataTables' own mobile rules
     * are `div.dt-container div.dt-length`, so a plain `.dt-container .dt-length`
     * loses on specificity and silently does nothing. Matched here, and app.css
     * is linked after dataTables.bootstrap5.css, so this wins.
     */
    div.dt-container div.dt-length,
    div.dt-container div.dt-search,
    div.dt-container div.dt-info { text-align: left; }
    div.dt-container div.dt-search label { display: block; margin-bottom: .25rem; }
    div.dt-container div.dt-search input { width: 100%; margin-left: 0; }

    /* Paging keeps DataTables' own centring — it puts the controls under the
       thumb, and overriding it would mean out-specifying `ul.pagination` for
       no gain. Wrapping is the part that matters: 10+ pages on one line
       overflows. */
    div.dt-container div.dt-paging .pagination { flex-wrap: wrap; margin-bottom: 0; }

    /* Once a table scrolls horizontally there is nothing to gain from wrapping
       inside it — "Rathi Steels Private Limited" over three lines just makes
       every row three times as tall while still not showing the far columns. */
    div.dt-container table.dataTable > thead > tr > th,
    div.dt-container table.dataTable > tbody > tr > td { white-space: nowrap; }
}
