/**
 * Game Application Styles
 * 
 * Styles for the "Формула Инноваций" game interface.
 * This includes all views: admin, gamemaster, player, login, etc.
 */

/* ==========================================================================
   Font Faces
   ========================================================================== */

@font-face {
    font-family: 'MontserratBold';
    src: url('../fonts/Montserrat-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'Montserrat';
    src: url('../fonts/Montserrat-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}

/* ==========================================================================
   CSS Variables & Base Reset
   ========================================================================== */

:root {
    --bg: #FFFFFF;
    --fg: #000000;
    --muted: #808080;
    --card: #EDEDF2;
    --accent: #ef7d00;
    --good: #27ae60;
    --warn: #f39c12;
    --border: #D1D1D1;
    --gap: 12px;
    --radius: 16px;
    --font: 'Montserrat', sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Typography
   ========================================================================== */

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    margin: 8px 0 12px;
}

h1 {
    font-size: 20px;
    font-family: 'MontserratBold', sans-serif;
}

h2 {
    font-size: 20px;
    font-family: 'MontserratBold', sans-serif;
}

h3 {
    font-size: 14px;
    color: var(--muted);
    font-family: 'MontserratBold', sans-serif;
}

p {
    color: #333333;
}

/* ==========================================================================
   Layout Components
   ========================================================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

.header,
.footer {
    background: transparent;
    border-bottom: 1px solid var(--border);
}

.footer {
    border-top: 1px solid var(--border);
    border-bottom: none;
}

.header .inner,
.footer .inner {
    display: flex;
    align-items: center;
    gap: var(--gap);
    padding: 10px 16px;
}

.header .spacer {
    flex: 1;
}

/* ==========================================================================
   Logo & Images
   ========================================================================== */

.logo-placeholder {
    display: block;
    width: 180px;
    height: 56px;
    position: relative;
    overflow: hidden;
}

.placeholder-img {
    width: 100%;
    height: 200px;
    display: block;
    position: relative;
    overflow: hidden;
}

.placeholder-img.ratio-16x9 {
    aspect-ratio: 16/9;
}

.placeholder-img.ratio-3x1 {
    aspect-ratio: 3/1;
}

.placeholder-img::after {
    content: attr(data-label);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 14px;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.placeholder-img img,
.logo-placeholder img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ==========================================================================
   Cards & Containers
   ========================================================================== */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

/* ==========================================================================
   Grid System
   ========================================================================== */

.grid {
    display: grid;
    gap: var(--gap);
}

.grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid.grid-custom-1-3-1 {
    grid-template-columns: 1fr 3fr 1fr;
}

.grid.grid-custom-1-3-1 > .card {
    min-width: 0;
    max-height: 180px;
}

/* ==========================================================================
   Flexbox Utilities
   ========================================================================== */

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

.row {
    display: flex;
    gap: var(--gap);
    align-items: center;
    flex-wrap: wrap;
}

.spaced {
    justify-content: space-between;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #FFFFFF;
    color: var(--fg);
    cursor: pointer;
    font-weight: 600;
    font-family: 'MontserratBold', sans-serif;
}

.btn.primary {
    background: var(--accent);
    color: #FFFFFF;
    border-color: transparent;
}

.btn.warn {
    background: #fffbe6;
    color: #f39c12;
}

.btn.ghost {
    background: transparent;
}

.btn[disabled] {
    opacity: .6;
    cursor: not-allowed;
}

/* ==========================================================================
   Badges & Status Indicators
   ========================================================================== */

.badge {
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 14px;
    color: var(--muted);
}

.kbd {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: #f5f5f5;
    border: 1px solid #dcdcdc;
    padding: 2px 6px;
    border-radius: 6px;
    color: #333;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.traffic-light {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--warn);
    box-shadow: 0 0 0 2px #e0e0e0 inset;
}

.traffic-light[data-state="done"] {
    background: var(--good);
}

.notice {
    color: var(--muted);
    font-size: 14px;
}

.small {
    font-size: 12px;
    color: var(--muted);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.table th,
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.table th {
    color: #333;
    font-weight: 600;
    background: #f5f5f5;
    font-family: 'MontserratBold', sans-serif;
}

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

.table .table-group-header td {
    background-color: #e0e0e0;
    font-weight: bold;
}

.table .table-group-footer {
    border-bottom: 2px solid var(--border) !important;
}

.table .table-group-footer td {
    border-bottom: none;
}

.table .text-center {
    text-align: center;
}

/* Teams Table Layout */
.table-teams-layout {
    table-layout: fixed;
    width: 100%;
}

.table-teams-layout th:nth-child(1) {
    width: 33.33%;
}

.table-teams-layout th:nth-child(2) {
    width: 25%;
}

.table-teams-layout th:nth-child(3) {
    width: 25%;
}

.table-teams-layout th:nth-child(4) {
    width: 16.67%;
}

/* Table Text Sizes */
.th-large {
    font-size: 16px;
}

.td-large-text {
    font-size: 16px;
}

.td-xlarge-badge {
    font-size: 20px;
}

.td-large-status .traffic-light {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Timer & Timeline
   ========================================================================== */

.timer {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    font-size: 56px;
    font-weight: 700;
}

.timeline {
    height: 16px;
    background: #f0f0f0;
    border: 1px solid var(--border);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
}

.timeline .bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 30%;
    background: linear-gradient(90deg, #ef7d00, #ff9a3b);
}

/* ==========================================================================
   Team Cards
   ========================================================================== */

.team-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.team-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ==========================================================================
   Podium (Final Results)
   ========================================================================== */

.podium {
    position: relative;
}

.podium-1 {
    border: 2px solid gold;
    box-shadow: 0 0 0 2px rgba(255, 215, 0, .18);
}

.podium-2 {
    border: 2px solid silver;
    box-shadow: 0 0 0 2px rgba(192, 192, 192, .18);
}

.podium-3 {
    border: 2px solid #cd7f32;
    box-shadow: 0 0 0 2px rgba(205, 127, 50, .18);
}

/* ==========================================================================
   Router Views
   ========================================================================== */

.view {
    display: none;
}

.view.active {
    display: block;
}

nav .badge.active {
    background: #ffe8d1;
}

/* ==========================================================================
   Form Controls
   ========================================================================== */

.form-control {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: #fff;
    font-family: var(--font);
    font-size: 14px;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.form-control:focus {
    border-color: var(--accent);
    outline: 0;
    box-shadow: 0 0 0 2px rgba(239, 125, 0, 0.25);
}

/* Remove number input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

/* Form validation states */
.form-control.is-valid {
    border-color: var(--good);
    background-color: #f0fff4;
}

.form-control.is-invalid {
    border-color: #e53e3e;
    background-color: #fff5f5;
}

/* ==========================================================================
   Gamemaster Table Layout
   ========================================================================== */

.gm-table-layout {
    table-layout: fixed;
    align-self: center;
    width: 60%;
}

.gm-table-layout th:nth-child(1) {
    width: 30%;
}

.gm-table-layout th:nth-child(2) {
    width: 25%;
}

.gm-table-layout th:nth-child(3) {
    width: 25%;
}

.gm-table-layout th:nth-child(4) {
    width: 20%;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer .contacts {
    display: grid;
    gap: 6px;
    font-size: 14px;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 900px) {
    .grid.cols-2,
    .grid.cols-3,
    .grid.grid-custom-1-3-1 {
        grid-template-columns: 1fr;
    }

    .logo-placeholder {
        width: 140px;
        height: 48px;
    }
}

@media (max-width: 400px) {
    /* Constrain the main container on mobile to prevent stretching */
    .container {
        max-width: 900px;
        padding: 8px;
    }

    /* Stack the header controls on mobile */
    #view-gm .card .row.spaced {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* Make the GM table more compact */
    .gm-table th,
    .gm-table td {
        padding: 8px 4px;
        font-size: 12px;
    }

    /* Shorten the long header text by reducing its font size */
    .gm-table th:nth-child(2) {
        font-size: 10px;
    }

    .gm-table-layout {
        table-layout: fixed;
        align-self: center;
        width: 100%;
    }

    .gm-table-layout th:nth-child(1) {
        width: 30%;
    }

    .gm-table-layout th:nth-child(2) {
        width: 20%;
    }

    .gm-table-layout th:nth-child(3) {
        width: 25%;
    }

    .gm-table-layout th:nth-child(4) {
        width: 25%;
    }

    /* Make the input fields smaller */
    .gm-table .form-control {
        width: 100%;
        padding: 4px 6px;
        font-size: 12px;
    }
}

