* {
    box-sizing: border-box;
    outline-offset: 1px;
}

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;

    background-color: #EDEDED;
    min-height: 100vh;
}

body, input, textarea {
    font-family: "Calibri", sans-serif;
    font-size: 18px;
}

header, footer {
    background-color: #002E5F;
    color: #FFFFFF;

    width: 100vw;
    padding-left: 1.5rem;
    padding-right: 1.5rem;

    display: flex;
    align-items: baseline;
    justify-content: space-between;

    flex-grow: 0;
}

header {
    top: 0;

    a {
        color: white;
        text-decoration: none;
    }

    a:visited {
        color: white;
    }
}

main {
    flex-grow: 10;
    display: flex;
    flex-direction: column;

    > * {
        margin: 0;
        background-color: #FFFFFF;
        padding: 1.5rem;
        width: 60rem;
    }

    configs {
        flex-grow: 10;
        padding-top: 0;
    }

    h2 {
        margin: 0;
        display: inline;
    }
}

h1, h2, h3 {
    font-weight: initial;
}

.topbox {
    background-color: #DCE4EE;
}

.config-intro {
    display: flex;
    justify-content: space-between;
    align-items: center;

    #create-config {
        justify-self: end;
    }
}

.vpnstatus {
    display: flex;
    justify-content: center;
    font-size: 1.3rem;
    background-color: #EEF9FA;
    color: #4B4B4B;

    p {
        margin: 0;
    }

    &.active {
        background-color: #BEC297;
    }

    &.error {
        color: #B00020;
    }
}

configs {
    background-color: #FFFFFF;
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr 1fr;
    align-content: start;
}

placeholder {
    display: none;

    &:only-child {
        display: block;
        color: #6A6A6A;
    }
}

.config, input, textarea {
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.config {
    display: grid;
    background-color: #EBF0F5;
    border: 2px solid #DCE4EE;
    border-radius: 0.5rem;
    gap: 0.2rem;

    > h3 {
        margin-top: 0;
    }

    > name {
        grid-area: name;
        align-self: baseline;
    }

    > description {
        grid-area: description;
        align-self: stretch;
    }

    > data {
        grid-area: data;
    }

    > expires {
        grid-area: date;
        align-self: baseline;
        color: #b00020;
    }

    > .qr {
        grid-area: qr;
        padding: 0.5rem;
        background-color: #FFFFFF !important;
        border: 2px solid #FFFFFF;
        border-radius: 0.5rem;
    }

    > .modal-bottom {
        grid-area: footer;
        place-self: end;
    }
}

qrcode > svg {
    width: 100%;
    height: 100%;
}

name {
    font-size: 1.5rem;
}

description, data {
    white-space: pre-wrap;
}

data, .conffile {
    display: none;
}

dialog {
    background-color: #FFFFFF;
    padding: 2rem;
    border: none;
    border-radius: 1rem;
    width: 58rem;
    height: 30rem;

    h3 {
        margin-top: 0;
    }

    form {
        height: 100%;
    }

    &::backdrop {
        background-color: rgba(0,0,0,0.6);
    }
}

form {
    display: flex;
    flex-direction: column;

    > .modal-bottom {
        margin-top: 0.5rem;
    }
}

h3, label {
    margin-top: 0.6rem;
    margin-bottom: 0.2rem;
}

a {
    color: #002f5f;
}
a:visited {
    color: #42678c;
}

input, textarea {
    border: 2px solid #DADADA;
}

textarea {
    flex-grow: 10;
}

.modal-bottom, left, right {
    display: flex;
}

footer, .modal-bottom {
    justify-content: space-between;
}

footer {
    font-size: 80%;
    padding-top: 0.5rem;
    padding-bottom: 1.5rem;

    > div {
        max-width: 30vw;
    }

    .su-name {
        font-size: 120%;
    }

    h2 {
        margin: 0;
    }

    a {
        color: #99c3ff;
    }
    a:visited {
        color: #ca94f9;
    }

    ul {
        margin: 0;
        padding-left: 1rem;
    }
}

button {
    color: #FFFFFF;
    background-color: #002E5F;
    border: 2px solid #33587F;
    border-radius: 0.5rem;
    padding: 0.5rem;
    white-space: nowrap;
    &:hover {
        background-color: #33587F;
    }

    &:disabled {
        color: #000000;
        background-color: #BABABA;
        border: 2px solid #DADADA;
    }

    &.cancel {
        color: #000000;
        background-color: #BABABA;
        border: 2px solid #DADADA;
        &:hover {
            background-color: #DADADA;
        }
    }

    &.delete {
        background-color: #D30000;
        border: 2px solid #E43B3B;
        &:hover {
            background-color: #E43B3B;
        }
    }

    &#create-config {
        font-size: 1.2rem;
    }
}

button + button {
    margin-left: 0.2rem;
    margin-right: 0.2rem;
}


@media (width <= 64rem) {
    dialog {
        width: 90vw;
    }
}

@media (width < 60rem) {
    main > * {
        width: 100vw;
    }

    .config {
        grid-template-areas:
            "name"
            "date"
            "description"
            "qr"
            "footer";
        grid-template-rows: min-content auto auto 280px 2.8rem;

        > .qr {
            justify-self: center;
            width: 280px;
            height: 280px;
        }
    }
}

@media (width >= 60rem), (width < 44rem) {
    .config {
        grid-template-areas:
            "name name"
            "date date"
            "description description"
            "qr footer";
        grid-template-rows: min-content auto auto 240px;

        > .qr {
            justify-self: start;
            align-self: start;
            height: 240px;
            width: 240px;
        }
    }
}


@media (width < 44rem) {
    configs {
        display: flex;
        flex-direction: column;
    }

    footer {
        flex-direction: column;
        padding-top: 1.5rem;

        > div {
            max-width: initial;
        }
        > div + div{
            margin-top: 1.5rem;
        }
    }
}

@media (width < 30rem) {
    .config-intro {
        flex-direction: column;
        align-items: flex-start;

        > h2 {
            margin-bottom: 1rem;
        }
    }

    .config {
        grid-template-areas:
            "name"
            "date"
            "description"
            "qr"
            "footer";
        grid-template-rows: min-content auto auto 280px 2.8rem;

        > .qr {
            justify-self: center;
            width: 280px;
            height: 280px;
        }

        > .modal-bottom {
            justify-self: start;
        }
    }
}

@media (width < 22em) {
    .config {
        display: flex;
        flex-direction: column;

        > .qr {
            width: auto;
            height: auto;
            max-width: 100%;
            max-height: 100%;
            margin-bottom: 0.5em;
        }

        > .modal-bottom {
            align-self: flex-start;
        }
    }
}

@media (height < 33.3rem) {
    dialog {
        height: 90vh;
    }
    textarea {
        min-height: auto;
    }
}
